Skip to content
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

predict doesn't work for FE-only models #258

Open
nilshg opened this issue Jan 30, 2024 · 0 comments
Open

predict doesn't work for FE-only models #258

nilshg opened this issue Jan 30, 2024 · 0 comments
Labels

Comments

@nilshg
Copy link
Contributor

nilshg commented Jan 30, 2024

This is sort of self-assigned:

julia> using FixedEffectModels, DataFrames

julia> df = DataFrame(y=rand(10), id = rand(1:2, 10), t = rand(1:2, 10));

julia> predict(reg(df, @formula(y ~ fe(id) + fe(t)), save = :fe), df)
ERROR: ArgumentError: collection must be non-empty
Stacktrace:
 [1] first(itr::@NamedTuple{})
   @ Base .\abstractarray.jl:470
 [2] missing_omit(d::@NamedTuple{})
   @ StatsModels C:\Users\ngudat\.julia\packages\StatsModels\syVEq\src\modelframe.jl:57
 [3] missing_omit(data::@NamedTuple{y::Vector{Float64}, id::Vector{Int64}, t::Vector{Int64}}, formula::MatrixTerm{Tuple{InterceptTerm{false}}})
   @ StatsModels C:\Users\ngudat\.julia\packages\StatsModels\syVEq\src\modelframe.jl:70
 [4] predict(m::FixedEffectModel, data::DataFrame)
   @ FixedEffectModels C:\Users\ngudat\.julia\packages\FixedEffectModels\9B0we\src\FixedEffectModel.jl:142
 [5] top-level scope
   @ REPL[34]:1

julia> predict(reg(df, @formula(y ~ id + fe(t)), save = :fe), df)
10-element Vector{Float64}:
(...)

a workaround is to add a column of ones:

df.x .= 1
reg(@formula(y ~ -1 + x + fe(id) + fe(t))

but that's clearly not ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants