Skip to content

Commit 41aacc9

Browse files
v1.0.0 (#25)
* v1.0.0 * Update Project.toml * Update README.md * Update fit.jl * Update InteractiveFixedEffectModels.jl * update * update
1 parent fd259e6 commit 41aacc9

File tree

8 files changed

+22
-84
lines changed

8 files changed

+22
-84
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: julia
22
julia:
3-
- 1.0
4-
- 1.1
5-
- 1.2
3+
- 1.3
4+
- 1.4
5+
- 1.5
66
- nightly
77
script:
88
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "InteractiveFixedEffectModels"
22
uuid = "80307280-efb2-5c5d-af8b-a9c15821677b"
3-
version = "0.6.4"
3+
version = "1.0.0"
44

55
[deps]
66
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
@@ -21,14 +21,14 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
2121
DataFrames = "0.19, 0.20, 0.21"
2222
Distributions = "0"
2323
FillArrays = "0"
24-
FixedEffectModels = "0.10.3, 0.10.4, 0.11"
25-
FixedEffects = "0.7"
24+
FixedEffectModels = "0.11, 1"
25+
FixedEffects = "0.7, 1"
2626
LeastSquaresOptim = "0.7"
2727
Reexport = "0"
2828
StatsBase = "0"
2929
StatsModels = "0.6"
3030
Tables = "0, 1"
31-
julia = "1"
31+
julia = "1.3"
3232

3333
[extras]
3434
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ The definition of interactive fixed effects follows Bai (2009).Formally, denote
1717
using DataFrames, RDatasets, InteractiveFixedEffectModels
1818
df = dataset("plm", "Cigar")
1919
regife(df, @formula(Sales ~ Price + ife(State, Year, 2) + fe(State)))
20-
# Linear Factor Model
21-
#================================================================
22-
#Number of obs: 1380 Degree of freedom: 199
23-
#R2: 0.976 R2 within: 0.435
24-
#Iterations: 436 Converged: true
25-
#================================================================
26-
# Estimate Std.Error t value Pr(>|t|) Lower 95% Upper 95%
27-
#----------------------------------------------------------------
28-
#Price -0.425372 0.0141163 -30.1334 0.000 -0.453068 -0.397677
29-
#================================================================
20+
Interactive Fixed Effect Model
21+
================================================================
22+
Number of obs: 1380 Degree of freedom: 47
23+
R2: 0.976 R2 within: 0.435
24+
Iterations: 436 Converged: true
25+
================================================================
26+
Estimate Std.Error t value Pr(>|t|) Lower 95% Upper 95%
27+
----------------------------------------------------------------
28+
Price -0.425372 0.0132871 -32.0139 0.000 -0.451438 -0.399306
29+
================================================================
3030
```
3131

3232

src/InteractiveFixedEffectModels.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ module InteractiveFixedEffectModels
55
##
66
##############################################################################
77

8-
98
using Base
109
using LinearAlgebra
1110
using Statistics
1211
using Printf
13-
14-
1512
using StatsBase
1613
using StatsModels
1714
using Tables
@@ -23,10 +20,6 @@ using Reexport
2320
using FixedEffects
2421
@reexport using FixedEffectModels
2522

26-
27-
if !isdefined(FixedEffectModels, :ModelTerm)
28-
ModelTerm = Model
29-
end
3023
##############################################################################
3124
##
3225
## Exported methods and types
@@ -46,5 +39,4 @@ include("types.jl")
4639
include("methods/gauss_seidel.jl")
4740
include("methods/ls.jl")
4841
include("fit.jl")
49-
include("deprecated.jl")
5042
end

src/deprecated.jl

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/fit.jl

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11

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
102

113
function regife(df, f::FormulaTerm, vcov::CovarianceEstimator = Vcov.simple();
124
weights::Union{Symbol, Nothing} = nothing,
@@ -16,56 +8,26 @@ function regife(df, f::FormulaTerm, vcov::CovarianceEstimator = Vcov.simple();
168
maxiter::Integer = 10_000,
179
tol::Real = 1e-9,
1810
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}())
2412

2513
##############################################################################
2614
##
2715
## Transform DataFrame -> Matrix
2816
##
2917
##############################################################################
3018
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-
4619
if (ConstantTerm(0) FixedEffectModels.eachterm(f.rhs)) & (ConstantTerm(1) FixedEffectModels.eachterm(f.rhs))
4720
formula = FormulaTerm(f.lhs, tuple(ConstantTerm(1), FixedEffectModels.eachterm(f.rhs)...))
4821
end
4922

5023
formula, formula_endo, formula_iv = FixedEffectModels.parse_iv(f)
5124

5225
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
6126
has_weights = (weights != nothing)
6227

6328

6429
## create a dataframe without missing values & negative weightss
6530
vars = StatsModels.termvars(formula)
66-
if feformula != nothing # remove after depreciation
67-
vars = vcat(vars, StatsModels.termvars(@eval(@formula(0 ~ $(feformula)))))
68-
end
6931
factor_vars = [m.id, m.time]
7032
all_vars = unique(vcat(vars, factor_vars))
7133
esample = completecases(df[!, all_vars])
@@ -101,10 +63,6 @@ function regife(df, f::FormulaTerm, vcov::CovarianceEstimator = Vcov.simple();
10163
end
10264
end
10365
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
10866
has_fes = !isempty(fes)
10967
has_fes_intercept = false
11068
## Compute factors, an array of AbtractFixedEffects

test/factormodel.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using DataFrames, InteractiveFixedEffectModels,Test, CSV
2-
df = df = CSV.read(joinpath(dirname(pathof(InteractiveFixedEffectModels)), "../dataset/Cigar.csv"))
2+
df = df = DataFrame(CSV.File(joinpath(dirname(pathof(InteractiveFixedEffectModels)), "../dataset/Cigar.csv")))
33

44
for method in [:gauss_seidel, :dogleg, :levenberg_marquardt]
55
println(method)

test/interactivefixedeffectsmodel.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using DataFrames, InteractiveFixedEffectModels, CSV, LinearAlgebra, Test
22

33
precision = 2e-1
4-
df = CSV.read(joinpath(dirname(pathof(InteractiveFixedEffectModels)), "../dataset/Cigar.csv"))
4+
df = DataFrame(CSV.File(joinpath(dirname(pathof(InteractiveFixedEffectModels)), "../dataset/Cigar.csv")))
55

66

77

@@ -73,15 +73,15 @@ precision = 2e-1
7373
for method in [:levenberg_marquardt, :dogleg]
7474
println(method)
7575

76-
df = CSV.read(joinpath(dirname(pathof(InteractiveFixedEffectModels)), "../dataset/Cigar.csv"))
76+
local df = DataFrame(CSV.File(joinpath(dirname(pathof(InteractiveFixedEffectModels)), "../dataset/Cigar.csv")))
7777
df.State = categorical(df.State)
7878
df.Year = categorical(df.Year)
7979
model = @formula Sales ~ Price + ife(State, Year, 1) + fe(State)
8080
result = regife(df, model, weights = :Pop, method = method, save = true)
8181
model = @formula Sales ~ Price + ife(State, Year, 2) + fe(State)
8282
result = regife(df, model, weights = :Pop, method = method, save = true)
8383

84-
df = CSV.read(joinpath(dirname(pathof(InteractiveFixedEffectModels)), "../dataset/EmplUK.csv"))
84+
local df = DataFrame(CSV.File(joinpath(dirname(pathof(InteractiveFixedEffectModels)), "../dataset/EmplUK.csv")))
8585
df.id1 = df.Firm
8686
df.id2 = df.Year
8787
df.pid1 = categorical(df.id1)

0 commit comments

Comments
 (0)