Skip to content

Commit

Permalink
Remove depreciations (#115)
Browse files Browse the repository at this point in the history
* update to FixedEffects 0.7.4

* up

* Update .gitlab-ci.yml

* update

* remove deprecated

* Update README.md
  • Loading branch information
matthieugomez committed Aug 5, 2020
1 parent 0468ca6 commit e3aa1e2
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 216 deletions.
Binary file removed .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Expand Up @@ -3,5 +3,5 @@ variables:

include:
- 'https://raw.githubusercontent.com/JuliaGPU/gitlab-ci/master/templates/v4/common.yml'
- 'https://raw.githubusercontent.com/JuliaGPU/gitlab-ci/master/templates/v4/test_v1.1.yml'
- 'https://raw.githubusercontent.com/JuliaGPU/gitlab-ci/master/templates/v4/test_v1.3.yml'
- 'https://raw.githubusercontent.com/JuliaGPU/gitlab-ci/master/templates/v4/test_dev.yml'
8 changes: 4 additions & 4 deletions Project.toml
@@ -1,6 +1,6 @@
name = "FixedEffectModels"
uuid = "9d5cd8c9-2029-5cab-9928-427838db53e3"
version = "0.10.9"
version = "0.11.0"

[deps]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Expand All @@ -18,15 +18,15 @@ StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[compat]
Combinatorics = "0, 1.0"
DataFrames = "0.19, 0.20, 0.21"
Combinatorics = "0, 1"
DataFrames = "0.21"
Distributions = "0"
FillArrays = "0"
FixedEffects = "0.7.4"
Reexport = "0"
StatsBase = "0.32, 0.33"
StatsModels = "0.6"
Tables = "0, 1.0"
Tables = "1"
julia = "1.3"

[extras]
Expand Down
30 changes: 11 additions & 19 deletions README.md
@@ -1,7 +1,6 @@
[![Build Status](https://travis-ci.com/FixedEffects/FixedEffectModels.jl.svg?branch=master)](https://travis-ci.com/FixedEffects/FixedEffectModels.jl)
[![pipeline status](https://gitlab.com/JuliaGPU/FixedEffectModels.jl/badges/master/pipeline.svg)](https://gitlab.com/JuliaGPU/FixedEffectModels.jl/commits/master)

This package estimates linear models with high dimensional categorical variables and/or instrumental variables.
This package estimates linear models with high dimensional categorical variables and/or instrumental variables.

Its objective is similar to the Stata command [`reghdfe`](https://github.com/sergiocorreia/reghdfe) and the R function [`felm`](https://cran.r-project.org/web/packages/lfe/lfe.pdf). The package tends to be much faster than these two options.

Expand Down Expand Up @@ -31,13 +30,13 @@ reg(df, @formula(Sales ~ NDI + fe(State) + fe(Year)), Vcov.cluster(:State), weig


- A typical formula is composed of one dependent variable, exogeneous variables, endogeneous variables, instrumental variables, and a set of high-dimensional fixed effects.

```julia
dependent variable ~ exogenous variables + (endogenous variables ~ instrumental variables) + fe(fixedeffect variable)
```

High-dimensional fixed effect variables are indicated with the function `fe`. You can add an arbitrary number of high dimensional fixed effects, separated with `+`. You can also interact fixed effects using `&` or `*`.
High-dimensional fixed effect variables are indicated with the function `fe`. You can add an arbitrary number of high dimensional fixed effects, separated with `+`. You can also interact fixed effects using `&` or `*`.

For instance, to add state fixed effects use `fe(State)`. To add both state and year fixed effects, use `fe(State) + fe(Year)`. To add state-year fixed effects, use `fe(State)&fe(Year)`. To add state specific slopes for year, use `fe(State)&Year`. To add both state fixed-effects and state specific slopes for year use `fe(State)*Year`.

```julia
Expand All @@ -62,22 +61,22 @@ reg(df, @formula(Sales ~ NDI + fe(State) + fe(Year)), Vcov.cluster(:State), weig
```julia
weights = :Pop
```
- The option `subset` specifies a subset of the data
- The option `subset` specifies a subset of the data
```julia
subset = df.State .>= 30
```
- The option `save` can be set to one of the following: `:residuals` to save residuals, `:fe` to save fixed effects, `true` to save both. You can access the result with `residuals()` and `fe()`

- The option `method` can be set to one of the following: `:cpu`, `:gpu` (see Performances below).

- The option `contrasts` specifies particular contrasts for categorical variables in the formula, e.g.
- The option `contrasts` specifies particular contrasts for categorical variables in the formula, e.g.
```julia
df.YearC = categorical(df.Year)
reg(df, @formula(Sales ~ YearC); contrasts = Dict(:YearC => DummyCoding(base = 80)))
```
## Output
`reg` returns a light object. It is composed of
`reg` returns a light object. It is composed of

- the vector of coefficients & the covariance matrix (use `coef`, `coefnames`, `vcov` on the output of `reg`)
- a boolean vector reporting rows used in the estimation
- a set of scalars (number of observations, the degree of freedoms, r2, etc)
Expand All @@ -90,13 +89,10 @@ Methods such as `predict`, `residuals` are still defined but require to specify
You may use [RegressionTables.jl](https://github.com/jmboehm/RegressionTables.jl) to get publication-quality regression tables.


## Performances
#### GPU
## GPU
The package has support for GPUs (Nvidia) (thanks to Paul Schrimpf). This can make the package an order of magnitude faster for complicated problems.

First make sure to do `using CUDA` before `using FixedEffectModels`. Then, estimate a model with `method = :gpu`.

When working on the GPU, it is encouraged to set the floating point precision to `Float32` with `double_precision = false`, since it is usually much faster.
To use GPU, run `using CUDA` before `using FixedEffectModels`. Then, estimate a model with `method = :gpu`. For maximum speed, set the floating point precision to `Float32` with `double_precision = false`.

```julia
using CUDA, FixedEffectModels
Expand Down Expand Up @@ -124,10 +120,6 @@ Fong, DC. and Saunders, M. (2011) *LSMR: An Iterative Algorithm for Sparse Least

Gaure, S. (2013) *OLS with Multiple High Dimensional Category Variables*. Computational Statistics and Data Analysis

Kleibergen, F, and Paap, R. (2006) *Generalized reduced rank tests using the singular value decomposition.* Journal of econometrics
Kleibergen, F, and Paap, R. (2006) *Generalized reduced rank tests using the singular value decomposition.* Journal of econometrics

Kleibergen, F. and Schaffer, M. (2007) *RANKTEST: Stata module to test the rank of a matrix using the Kleibergen-Paap rk statistic*. Statistical Software Components, Boston College Department of Economics.




13 changes: 2 additions & 11 deletions src/FixedEffectModels.jl
Expand Up @@ -6,7 +6,6 @@ module FixedEffectModels
## Dependencies
##
##############################################################################
using Base
using LinearAlgebra
using Statistics
using Printf
Expand All @@ -15,11 +14,10 @@ using DataFrames
using Distributions
using Reexport
using Tables
using FixedEffects
@reexport using StatsBase
@reexport using StatsModels

using FixedEffects

##############################################################################
##
## Exported methods and types
Expand All @@ -29,16 +27,10 @@ using FixedEffects
export reg,
partial_out,
fe,

FixedEffectModel,
has_iv,
has_fe,

Vcov,

#deprecated
@model,
fes
Vcov

##############################################################################
##
Expand All @@ -58,6 +50,5 @@ include("FixedEffectModel.jl")
include("fit.jl")
include("partial_out.jl")

include("deprecated.jl")

end # module FixedEffectModels
156 changes: 0 additions & 156 deletions src/deprecated.jl

This file was deleted.

27 changes: 2 additions & 25 deletions src/fit.jl
Expand Up @@ -43,24 +43,9 @@ function reg(@nospecialize(df),
method::Symbol = :cpu,
drop_singletons = true,
double_precision::Bool = true,
tol::Real = double_precision ? 1e-8 : 1e-6,
@nospecialize(feformula::Union{Symbol, Expr, Nothing} = nothing),
@nospecialize(vcovformula::Union{Symbol, Expr, Nothing} = nothing),
@nospecialize(subsetformula::Union{Symbol, Expr, Nothing} = nothing))
tol::Real = double_precision ? 1e-8 : 1e-6)

df = DataFrame(df; copycols = false)
# to deprecate
if vcovformula != nothing
if (vcovformula == :simple) | (vcovformula == :(simple()))
vcov = Vcov.Simple()
elseif (vcovformula == :robust) | (vcovformula == :(robust()))
vcov = Vcov.Robust()
else
vcov = Vcov.cluster(StatsModels.termvars(@eval(@formula(0 ~ $(vcovformula.args[2]))))...)
end
end
if subsetformula != nothing
subset = eval(evaluate_subset(df, subsetformula))
end

##############################################################################
##
Expand Down Expand Up @@ -96,9 +81,6 @@ function reg(@nospecialize(df),

# create a dataframe without missing values & negative weights
vars = StatsModels.termvars(formula)
if feformula != nothing # to deprecate
vars = vcat(vars, StatsModels.termvars(@eval(@formula(0 ~ $(feformula)))))
end
iv_vars = Symbol[]
endo_vars = Symbol[]
if has_iv
Expand All @@ -121,11 +103,6 @@ function reg(@nospecialize(df),
end
fes, ids, formula = parse_fixedeffect(df, formula)
has_fes = !isempty(fes)
if feformula != nothing
has_fes = true
feformula = @eval(@formula(0 ~ $(feformula)))
fes, ids = oldparse_fixedeffect(df, feformula)
end
if has_fes
if drop_singletons
for fe in fes
Expand Down

2 comments on commit e3aa1e2

@matthieugomez
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/19114

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.11.0 -m "<description of version>" e3aa1e22fa11f28a06214e74d8b22090be56f86e
git push origin v0.11.0

Please sign in to comment.