FixedEffectModels.parse_fixedeffect
— Methodparse_fixedeffect(data, formula::FormulaTerm)
parse_fixedeffect(data, ts::NTuple{N, AbstractTerm})
Construct any FixedEffect
specified with a FixedEffectTerm
.
Returns
Vector{FixedEffect}
: a collection of allFixedEffect
s constructed.Vector{Symbol}
: names assigned to the fixed effect estimates (can be used as column names).Vector{Symbol}
: names of original fixed effects.FormulaTerm
orNTuple{N, AbstractTerm}
:formula
orts
without any term related to fixed effects (an intercept may be explicitly omitted if necessary).
FixedEffectModels.partial_out
— MethodPartial out variables in a Dataframe
Arguments
df
: A tableformula::FormulaTerm
: A formula created using@formula
add_mean::Bool
: Should the initial mean added to the returned variable?method::Symbol
: A symbol for the method. Default is :cpu. Alternatively, :gpu requiresCuArrays
. In this case, use the optiondouble_precision = false
to useFloat32
.maxiter::Integer
: Maximum number of iterationsdouble_precision::Bool
: Should the demeaning operation use Float64 rather than Float32? Default to true.tol::Real
: Tolerancealign::Bool
: Should the returned DataFrame align with the original DataFrame in case of missing values? Default to true
Returns
::DataFrame
: a dataframe with as many columns as there are dependent variables and as many rows as the original dataframe.::Vector{Int}
: a vector of iterations for each column::Vector{Bool}
: a vector of success for each column
Details
partial_out
returns the residuals of a set of variables after regressing them on a set of regressors. The syntax is similar to reg
- but it accepts multiple dependent variables. It returns a dataframe with as many columns as there are dependent variables and as many rows as the original dataframe. The regression model is estimated on only the rows where none of the dependent variables is missing. With the option add_mean = true
, the mean of the initial variable is added to the residuals.
Examples
using RDatasets, DataFrames, FixedEffectModels, Gadfly
df = dataset("datasets", "iris")
result = partial_out(df, @formula(SepalWidth + SepalLength ~ fe(Species)), add_mean = true)
plot(layer(result[1], x="SepalWidth", y="SepalLength", Stat.binmean(n=10), Geom.point),
layer(result[1], x="SepalWidth", y="SepalLength", Geom.smooth(method=:lm)))