Skip to content

Fix compatibility issue with FixedEffectModels.jl v1.11 #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
version:
- '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'.
- '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'.
Copy link
Preview

Copilot AI Apr 17, 2025

Choose a reason for hiding this comment

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

The inline comment still references Julia 1.5 as the minimum version. Please update the comment to accurately reflect that the new minimum supported version is 1.9.

Suggested change
- '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'.
- '1.9' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.9 or higher, change this to '1.9'.

Copilot uses AI. Check for mistakes.

- '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
os:
- ubuntu-latest
Expand All @@ -27,7 +27,7 @@ jobs:
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ StatsModels = "0.7"
StatsFuns = "0.9, 1"
Tables = "1"
Vcov = "0.8"
julia = "1.6"
julia = "1.9"

[extras]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Expand Down
6 changes: 3 additions & 3 deletions src/fit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ function regife(
Symbol(fesymbol(a)) ∉ factor_vars && error("FixedEffect should correspond to id or time dimension of the factor model")
end
end
fes, ids, fekeys, formula = FixedEffectModels.parse_fixedeffect(df, formula)
fes, ids, fekeys, formula = parse_fixedeffect(df, formula)
has_fes = !isempty(fes)
has_fes_intercept = false
## Compute factors, an array of AbtractFixedEffects
if has_fes
if any([isa(fe.interaction, Ones) for fe in fes])
if any([isa(fe.interaction, UnitWeights) for fe in fes])
formula = FormulaTerm(formula.lhs, tuple(ConstantTerm(0), (t for t in eachterm(formula.rhs) if t!= ConstantTerm(1))...))
has_fes_intercept = true
end
Expand All @@ -93,7 +93,7 @@ function regife(

##############################################################################
##
## Construict vector y and matrix X
## Construct vector y and matrix X
##
##############################################################################
subdf = Tables.columntable((; (x => disallowmissing(view(df[!, x], esample)) for x in unique(vcat(vars)))...))
Expand Down
10 changes: 10 additions & 0 deletions src/utils/formula.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ eachterm(@nospecialize(x::NTuple{N, AbstractTerm})) where {N} = x
##############################################################################
fesymbol(t::FixedEffectModels.FixedEffectTerm) = t.x
fesymbol(t::FunctionTerm{typeof(fe)}) = Symbol(t.args[1])

function parse_fixedeffect(df, formula)
if isdefined(FixedEffectModels, :parse_fe)
formula, formula_fes = FixedEffectModels.parse_fe(formula)
fes, ids, fekeys = FixedEffectModels.parse_fixedeffect(df, formula_fes)
else
fes, ids, fekeys, formula = FixedEffectModels.parse_fixedeffect(df, formula)
end
return fes, ids, fekeys, formula
end