You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/ci.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ jobs:
15
15
fail-fast: false
16
16
matrix:
17
17
version:
18
-
- '1.6'# Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
18
+
- '1.9'# Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
19
19
- '1'# Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
- The option `save` can be set to one of the following: `:none` (default) to save nothing, `:residuals` to save residuals, `:fe` to save fixed effects, and `:all` to save both. Once saved, they can then be accessed using `residuals(m)` or `fe(m)` where `m` is the estimated model (the object returned by the function `reg`). Both residuals and fixed effects are aligned with the original dataframe used to estimate the model.
80
80
81
-
- The option `method` can be set to one of the following: `:cpu`, `:gpu` (see Performances below).
81
+
- The option `method` can be set to one of the following: `:cpu`, `:CUDA`, or `:Metal` (see Performances below).
82
82
83
83
84
84
## Output
@@ -99,17 +99,27 @@ You may use [RegressionTables.jl](https://github.com/jmboehm/RegressionTables.jl
99
99
### MultiThreads
100
100
`FixedEffectModels` is multi-threaded. Use the option `nthreads` to select the number of threads to use in the estimation (defaults to `Threads.nthreads()`).
101
101
102
-
### Nvidia GPU
103
-
The package has support for Nvidia GPUs (thanks to Paul Schrimpf). This can make the package an order of magnitude faster for complicated problems.
102
+
### GPUs
103
+
The package has an experimental support for GPUs. This can make the package an order of magnitude faster for complicated problems.
104
104
105
-
If you have a Nvidia 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`.
105
+
If you have a Nvidia GPU, run `using CUDA` before `using FixedEffectModels`. Then, estimate a model with `method = :CUDA`.
106
106
107
107
```julia
108
108
using CUDA, FixedEffectModels
109
+
@assert CUDA.functional()
109
110
df =dataset("plm", "Cigar")
110
-
reg(df, @formula(Sales ~ NDI +fe(State) +fe(Year)), method =:gpu, double_precision =false)
111
+
reg(df, @formula(Sales ~ NDI +fe(State) +fe(Year)), method =:CUDA)
111
112
```
112
113
114
+
The package also supports Apple GPUs with `Metal.jl`, although it does not really improve perfomances
115
+
```julia
116
+
using Metal, FixedEffectModels
117
+
@assert Metal.functional()
118
+
df =dataset("plm", "Cigar")
119
+
reg(df, @formula(Sales ~ NDI +fe(State) +fe(Year)), method =:Metal)
120
+
```
121
+
122
+
113
123
114
124
## Solution Method
115
125
Denote the model `y = X β + D θ + e` where X is a matrix with few columns and D is the design matrix from categorical variables. Estimates for `β`, along with their standard errors, are obtained in two steps:
Copy file name to clipboardExpand all lines: src/fit.jl
+13-8Lines changed: 13 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,9 @@ Estimate a linear model with high dimensional categorical variables / instrument
10
10
* `contrasts::Dict = Dict()` An optional Dict of contrast codings for each categorical variable in the `formula`. Any unspecified variables will have `DummyCoding`.
11
11
* `weights::Union{Nothing, Symbol}` A symbol to refer to a columns for weights
12
12
* `save::Symbol`: Should residuals and eventual estimated fixed effects saved in a dataframe? Default to `:none` Use `save = :residuals` to only save residuals, `save = :fe` to only save fixed effects, `save = :all` for both. Once saved, they can then be accessed using `residuals(m)` or `fe(m)` where `m` is the object returned by the estimation. The returned DataFrame is automatically aligned with the original DataFrame.
13
-
* `method::Symbol`: A symbol for the method. Default is :cpu. Alternatively, :gpu requires `CuArrays`. In this case, use the option `double_precision = false` to use `Float32`.
14
-
* `nthreads::Integer` Number of threads to use in the estimation. If `method = :cpu`, defaults to `Threads.nthreads()`. If `method = :gpu`, defaults to 256.
15
-
* `double_precision::Bool`: Should the demeaning operation use Float64 rather than Float32? Default to true.
13
+
* `method::Symbol`: A symbol for the method. Default is :cpu. Alternatively, use :CUDA or :Metal (in this case, you need to import the respective package before importing FixedEffectModels)
14
+
* `nthreads::Integer` Number of threads to use in the estimation. If `method = :cpu`, defaults to `Threads.nthreads()`. Otherwise, defaults to 256.
15
+
* `double_precision::Bool`: Should the demeaning operation use Float64 rather than Float32? Default to true if `method =:cpu' and false if `method = :CUDA` or `method = :Metal`.
16
16
* `tol::Real` Tolerance. Default to 1e-6.
17
17
* `maxiter::Integer = 10000`: Maximum number of iterations
18
18
* `drop_singletons::Bool = true`: Should singletons be dropped?
# The C value adjusts the check to the relative scale of the variable. The C value is equal to the corrected sum of squares for the variable, unless the corrected sum of squares is 0, in which case C is 1. If you specify the NOINT option but not the ABSORB statement, PROC GLM uses the uncorrected sum of squares instead. The default value of the SINGULAR= option, 107, might be too small, but this value is necessary in order to handle the high-degree polynomials used in the literature to compare regression routin
56
56
tols =max.(diag(X), 1)
57
57
for j in1:size(X, 1)
@@ -69,6 +69,9 @@ function invsym!(X::AbstractMatrix)
0 commit comments