Skip to content

Commit 2e3bdfe

Browse files
Update requirements (#28)
* v1.0.0 * Update Project.toml * Update README.md * update
1 parent 41aacc9 commit 2e3bdfe

File tree

4 files changed

+41
-41
lines changed

4 files changed

+41
-41
lines changed

Project.toml

Lines changed: 7 additions & 6 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 = "1.0.0"
3+
version = "1.0.1"
44

55
[deps]
66
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
@@ -16,16 +16,17 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1616
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1717
StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
1818
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
19+
Vcov = "ec2bfdc2-55df-4fc9-b9ae-4958c2cf2486"
1920

2021
[compat]
21-
DataFrames = "0.19, 0.20, 0.21"
22+
DataFrames = "0.21"
2223
Distributions = "0"
23-
FillArrays = "0"
24-
FixedEffectModels = "0.11, 1"
25-
FixedEffects = "0.7, 1"
24+
FillArrays = "0.7, 0.8, 0.9"
25+
FixedEffectModels = "1.2"
26+
FixedEffects = "1.1"
2627
LeastSquaresOptim = "0.7"
2728
Reexport = "0"
28-
StatsBase = "0"
29+
StatsBase = "0.33"
2930
StatsModels = "0.6"
3031
Tables = "0, 1"
3132
julia = "1.3"

README.md

Lines changed: 10 additions & 15 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-
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-
================================================================
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

@@ -56,10 +56,6 @@ Price -0.425372 0.0132871 -32.0139 0.000 -0.451438 -0.399306
5656
```julia
5757
weights = :Pop
5858
```
59-
- The option `subset` estimates the model on a subset of the dataframe
60-
```julia
61-
subset = df.State .>= 30
62-
```
6359

6460
- The option `method` can be used to choose between two algorithms:
6561
- `:levenberg_marquardt`
@@ -68,7 +64,6 @@ Price -0.425372 0.0132871 -32.0139 0.000 -0.451438 -0.399306
6864
- The option `save = true` saves a new dataframe storing residuals, factors, loadings and the eventual fixed effects. Importantly, the returned dataframe is aligned with the initial dataframe (rows not used in the estimation are simply filled with `missing`s).
6965

7066

71-
7267
## FAQ
7368

7469

src/InteractiveFixedEffectModels.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ module InteractiveFixedEffectModels
44
## Dependencies
55
##
66
##############################################################################
7-
8-
using Base
7+
using DataFrames
8+
using Distributions
9+
using FillArrays
10+
using FixedEffects
11+
using LeastSquaresOptim
912
using LinearAlgebra
10-
using Statistics
1113
using Printf
14+
using Statistics
1215
using StatsBase
1316
using StatsModels
1417
using Tables
15-
using DataFrames
16-
using LeastSquaresOptim
17-
using FillArrays
18-
using Distributions
18+
using Vcov
19+
1920
using Reexport
20-
using FixedEffects
2121
@reexport using FixedEffectModels
2222

2323
##############################################################################

src/fit.jl

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11

22

3-
function regife(df, f::FormulaTerm, vcov::CovarianceEstimator = Vcov.simple();
4-
weights::Union{Symbol, Nothing} = nothing,
5-
subset::Union{AbstractVector, Nothing} = nothing,
6-
method::Symbol = :dogleg,
7-
lambda::Number = 0.0,
8-
maxiter::Integer = 10_000,
9-
tol::Real = 1e-9,
10-
save::Union{Bool, Nothing} = nothing,
11-
contrasts::Dict = Dict{Symbol, Any}())
3+
function regife(
4+
@nospecialize(df),
5+
@nospecialize(f::FormulaTerm),
6+
@nospecialize(vcov::CovarianceEstimator = Vcov.simple());
7+
@nospecialize(weights::Union{Symbol, Nothing} = nothing),
8+
@nospecialize(subset::Union{AbstractVector, Nothing} = nothing),
9+
@nospecialize(method::Symbol = :dogleg),
10+
@nospecialize(lambda::Number = 0.0),
11+
@nospecialize(maxiter::Integer = 10_000),
12+
@nospecialize(tol::Real = 1e-9),
13+
@nospecialize(save::Union{Bool, Nothing} = nothing),
14+
@nospecialize(contrasts::Dict = Dict{Symbol, Any}()))
1215

1316
##############################################################################
1417
##
@@ -52,10 +55,11 @@ function regife(df, f::FormulaTerm, vcov::CovarianceEstimator = Vcov.simple();
5255
# Compute weights
5356
if has_weights
5457
weights = Weights(convert(Vector{Float64}, view(df, esample, weights)))
58+
sqrtw = sqrt.(weights)
5559
else
56-
weights = Weights(Ones{Float64}(sum(esample)))
60+
weights = uweights(sum(esample))
61+
sqrtw = ones(length(weights))
5762
end
58-
sqrtw = sqrt.(weights)
5963
for a in FixedEffectModels.eachterm(formula.rhs)
6064
if has_fe(a)
6165
isa(a, InteractionTerm) && error("Fixed effects cannot be interacted")
@@ -120,7 +124,7 @@ function regife(df, f::FormulaTerm, vcov::CovarianceEstimator = Vcov.simple();
120124
# demean variables
121125
if has_fes
122126
FixedEffectModels.solve_residuals!(y, feM)
123-
FixedEffectModels.solve_residuals!(X, feM)
127+
FixedEffectModels.solve_residuals!(X, feM, progress_bar = false)
124128
end
125129

126130

0 commit comments

Comments
 (0)