1
1
2
- # #############################################################################
3
- # #
4
- # # Fit is the only exported function
5
- # #
6
- # #############################################################################
7
- function regife (df, m:: FixedEffectModels.ModelTerm ; kwargs... )
8
- regife (df, m. f; m. dict... , kwargs... )
9
- end
10
2
11
3
function regife (df, f:: FormulaTerm , vcov:: CovarianceEstimator = Vcov. simple ();
12
4
weights:: Union{Symbol, Nothing} = nothing ,
@@ -16,56 +8,26 @@ function regife(df, f::FormulaTerm, vcov::CovarianceEstimator = Vcov.simple();
16
8
maxiter:: Integer = 10_000 ,
17
9
tol:: Real = 1e-9 ,
18
10
save:: Union{Bool, Nothing} = nothing ,
19
- contrasts:: Dict = Dict {Symbol, Any} (),
20
- feformula:: Union{Symbol, Expr, Nothing} = nothing ,
21
- ifeformula:: Union{Symbol, Expr, Nothing} = nothing ,
22
- vcovformula:: Union{Symbol, Expr, Nothing} = nothing ,
23
- subsetformula:: Union{Symbol, Expr, Nothing} = nothing )
11
+ contrasts:: Dict = Dict {Symbol, Any} ())
24
12
25
13
# #############################################################################
26
14
# #
27
15
# # Transform DataFrame -> Matrix
28
16
# #
29
17
# #############################################################################
30
18
df = DataFrame (df; copycols = false )
31
-
32
- # to deprecate
33
- if vcovformula != nothing
34
- if (vcovformula == :simple ) | (vcovformula == :(simple ()))
35
- vcov = Vcov. Simple ()
36
- elseif (vcovformula == :robust ) | (vcovformula == :(robust ()))
37
- vcov = Vcov. Robust ()
38
- else
39
- vcov = Vcov. cluster (StatsModels. termvars (@eval (@formula (0 ~ $ (vcovformula. args[2 ]))))... )
40
- end
41
- end
42
- if subsetformula != nothing
43
- subset = eval (evaluate_subset (df, subsetformula))
44
- end
45
-
46
19
if (ConstantTerm (0 ) ∉ FixedEffectModels. eachterm (f. rhs)) & (ConstantTerm (1 ) ∉ FixedEffectModels. eachterm (f. rhs))
47
20
formula = FormulaTerm (f. lhs, tuple (ConstantTerm (1 ), FixedEffectModels. eachterm (f. rhs)... ))
48
21
end
49
22
50
23
formula, formula_endo, formula_iv = FixedEffectModels. parse_iv (f)
51
24
52
25
m, formula = parse_interactivefixedeffect (df, formula)
53
- if ifeformula != nothing # remove after depreciation
54
- m = OldInteractiveFixedEffectFormula (ifeformula)
55
- end
56
-
57
- # # parse formula
58
- if formula_iv != nothing
59
- error (" partial_out does not support instrumental variables" )
60
- end
61
26
has_weights = (weights != nothing )
62
27
63
28
64
29
# # create a dataframe without missing values & negative weightss
65
30
vars = StatsModels. termvars (formula)
66
- if feformula != nothing # remove after depreciation
67
- vars = vcat (vars, StatsModels. termvars (@eval (@formula (0 ~ $ (feformula)))))
68
- end
69
31
factor_vars = [m. id, m. time]
70
32
all_vars = unique (vcat (vars, factor_vars))
71
33
esample = completecases (df[! , all_vars])
@@ -101,10 +63,6 @@ function regife(df, f::FormulaTerm, vcov::CovarianceEstimator = Vcov.simple();
101
63
end
102
64
end
103
65
fes, ids, formula = FixedEffectModels. parse_fixedeffect (df, formula)
104
- if feformula != nothing # remove after depreciation
105
- feformula = @eval (@formula (0 ~ $ (feformula)))
106
- fes, ids = FixedEffectModels. oldparse_fixedeffect (df, feformula)
107
- end
108
66
has_fes = ! isempty (fes)
109
67
has_fes_intercept = false
110
68
# # Compute factors, an array of AbtractFixedEffects
0 commit comments