unfoldtoolbox / Unfold.jl

Neuroimaging (EEG, fMRI, pupil ...) regression analysis in Julia
MIT License
48 stars 10 forks source link

The `effects` function does not work for models of type `UnfoldLinearMixedModel` #113

Open jschepers opened 1 year ago

jschepers commented 1 year ago

When one calls the effects function for models of type UnfoldLinearMixedModel, one gets a MethodError:

Example:

data2, evts2 = UnfoldSim.predef_2x2(; n_subjects=5, return_epoched=true);
f2 = @formula(0 ~ 1 + A * B + (1 | subject));
τ2 = [-0.1, 1];
sfreq2 = 100;
times2 = range(τ2[1], length=size(data2, 1), step=1 ./ sfreq2);
m2 = Unfold.fit(UnfoldModel, Dict(Any => (f2, times2)), evts2, reshape(data2, 1, size(data2)...));

# Trying to use the `effects` function
conditions = Dict(:A => levels(evts2.A), :B => levels(evts2.B))
eff2 = effects(conditions, m2)

The last line leads to the following error:

julia> eff2 = effects(conditions, m2)
ERROR: MethodError: no method matching modelmatrix(::UnfoldLinearMixedModel, ::Bool)
Closest candidates are:
  modelmatrix(::StatsModels.FormulaTerm, ::Any; kwargs...) at ~/.julia/packages/StatsModels/fK0P3/src/modelframe.jl:92
  modelmatrix(::Union{Tuple{Union{Tuple{StatsModels.AbstractTerm, Vararg{StatsModels.AbstractTerm}}, StatsModels.AbstractTerm}, Vararg{Union{Tuple{StatsModels.AbstractTerm, Vararg{StatsModels.AbstractTerm}}, StatsModels.AbstractTerm}}}, StatsModels.AbstractTerm}, ::Any; hints, mod) at ~/.julia/packages/StatsModels/fK0P3/src/modelframe.jl:116
  modelmatrix(::StatsModels.TableRegressionModel, ::Any...; kwargs...) at ~/.julia/packages/StatsModels/fK0P3/src/statsmodel.jl:28
behinger commented 8 months ago

partially implemented. Still missing is the UnfoldMixedModelContinuous case