-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Description
I'm getting a method error on schema application when using a lead/lag term. I didn't think this was a GLM thing, but I'm happy to move this over there if it is a GLM thing.
EDIT: I slimmed the MWE down even more.
MWE:
using DataFrames, StatsModels, GLM
df = DataFrame(a = randn(10), b=randn(10))
f = @formula(a ~ 1 + lag(b, 1))
fitted = lm(f, df)
Error:
ERROR: MethodError: StatsModels.apply_schema(::FunctionTerm{typeof(lag),getfield(Main, Symbol("##383#384")),(:b,)}, ::StatsModels.FullRank, ::Type{LinearModel}) is ambiguous. Candidates:
apply_schema(t::AbstractTerm, schema::StatsModels.FullRank, Mod::Type) in StatsModels at /home/cameron/.julia/packages/StatsModels/G9zlM/src/schema.jl:313
apply_schema(t::FunctionTerm{F,Fanon,Names} where Names where Fanon, sch, ctx::Type) where F<:Union{typeof(lag), typeof(lead)} in StatsModels at /home/cameron/.julia/packages/StatsModels/G9zlM/src/temporal_terms.jl:30
Possible fix, define
apply_schema(::FunctionTerm{F<:Union{typeof(lag), typeof(lead)},Fanon,Names} where Names where Fanon, ::StatsModels.FullRank, ::Type)
Stacktrace:
[1] _broadcast_getindex_evalf(::typeof(apply_schema), ::FunctionTerm{typeof(lag),getfield(Main, Symbol("##383#384")),(:b,)}, ::StatsModels.FullRank, ::Type) at ./broadcast.jl:578
[2] _broadcast_getindex at ./broadcast.jl:551 [inlined]
[3] (::getfield(Base.Broadcast, Symbol("##19#20")){Base.Broadcast.Broadcasted{Base.Broadcast.Style{Tuple},Nothing,typeof(apply_schema),Tuple{Tuple{ConstantTerm{Int64},FunctionTerm{typeof(lag),getfield(Main, Symbol("##383#384")),(:b,)}},Base.RefValue{StatsModels.FullRank},Base.RefValue{Type{LinearModel}}}}})(::Int64) at ./broadcast.jl:953
[4] ntuple at ./tuple.jl:160 [inlined]
Metadata
Metadata
Assignees
Labels
No labels