@@ -12,7 +12,7 @@ function regife(df, m::FixedEffectModels.ModelTerm; kwargs...)
12
12
regife (df, m. f; m. dict... , kwargs... )
13
13
end
14
14
15
- function regife (df, f:: FormulaTerm , vcov:: Vcov.AbstractVcov = Vcov. simple ();
15
+ function regife (df, f:: FormulaTerm , vcov:: CovarianceEstimator = Vcov. simple ();
16
16
weights:: Union{Symbol, Nothing} = nothing ,
17
17
subset:: Union{AbstractVector, Nothing} = nothing ,
18
18
method:: Symbol = :dogleg ,
@@ -70,10 +70,10 @@ function regife(df, f::FormulaTerm, vcov::Vcov.AbstractVcov = Vcov.simple();
70
70
if feformula != nothing # remove after depreciation
71
71
vars = vcat (vars, StatsModels. termvars (@eval (@formula (0 ~ $ (feformula)))))
72
72
end
73
- vcov_vars = StatsModels. termvars (vcov)
74
73
factor_vars = [m. id, m. time]
75
- all_vars = unique (vcat (vars, factor_vars, vcov_vars ))
74
+ all_vars = unique (vcat (vars, factor_vars))
76
75
esample = completecases (df[! , all_vars])
76
+ esample .&= completecases (df, vcov)
77
77
if has_weights
78
78
esample .&= BitArray (! ismissing (x) & (x > 0 ) for x in df[! , weights])
79
79
all_vars = unique (vcat (all_vars, weights))
@@ -88,7 +88,7 @@ function regife(df, f::FormulaTerm, vcov::Vcov.AbstractVcov = Vcov.simple();
88
88
89
89
90
90
# Compute data needed for errors
91
- vcov_method_data = Vcov. VcovMethod (df[esample, unique ( Symbol .(vcov_vars))], vcov )
91
+ vcov_method_data = Vcov. materialize (vcov, view (df, esample,:) )
92
92
93
93
# Compute weights
94
94
sqrtw = Ones {Float64} (sum (esample))
@@ -260,8 +260,8 @@ function regife(df, f::FormulaTerm, vcov::Vcov.AbstractVcov = Vcov.simple();
260
260
dof_residual = max (size (X, 1 ) - size (X, 2 ) - df_absorb_fe, 1 )
261
261
262
262
# # estimate vcov matrix
263
- vcov_data = Vcov . VcovData (Xm, crossxm, residualsm, dof_residual)
264
- matrix_vcov = Vcov . vcov! (vcov_method_data, vcov_data )
263
+ vcov_data = FixedEffectModels . VcovData (Xm, crossxm, residualsm, dof_residual)
264
+ matrix_vcov = StatsBase . vcov (vcov_data, vcov_method_data )
265
265
# compute various r2
266
266
nobs = sum (esample)
267
267
rss = sum (abs2, residualsm)
@@ -318,7 +318,7 @@ function regife(df, f::FormulaTerm, vcov::Vcov.AbstractVcov = Vcov.simple();
318
318
if ! has_regressors
319
319
return FactorResult (esample, augmentdf, rss, iterations, converged)
320
320
else
321
- return InteractiveFixedEffectModel (fs. b, matrix_vcov, esample, augmentdf,
321
+ return InteractiveFixedEffectModel (fs. b, matrix_vcov, vcov, esample, augmentdf,
322
322
coef_names, yname, f, nobs, dof_residual, r2, r2_a, r2_within,
323
323
rss, sum (iterations), all (converged))
324
324
end
0 commit comments