StatsModels.jl
StatsModels.jl copied to clipboard
Potential bug in fit(Type, formula, data, contrasts = d, ...)
model = fit(LinearMixedModel,
@formula(AUC ~ formulation + sequence + period + (1|subject)),
data,
contrasts = Dict(:period => EffectsCoding()))
yields
MethodError: no method matching fit(::Type{LinearMixedModel}, Matrix{Float64}, Vector{Int})
The long-hand,
model = LinearMixedModel(@formula(AUC ~ formulation + sequence + period + (1|subject)),
data,
contrasts = Dict(:period => EffectsCoding()))
fit!(model)
works just fine.
@dmbates, I suspect the issue is in StatsModels.jl statsmodel.jl macro, but just in case there is something at MixedModels that might be triggering it.
Please provide a complete example.
using DataFrames, StatsModels, MixedModels
data = DataFrame(subject = categorical(repeat(1:32, inner = 2)),
sequence = categorical(["RT", "RT", "TR", "TR", "TR", "TR", "RT", "RT", "RT", "RT", "TR", "TR", "TR", "TR", "RT", "RT", "RT","RT", "TR", "TR", "RT", "RT", "TR", "TR", "TR", "TR", "RT", "RT", "RT", "RT", "TR", "TR", "RT", "RT", "TR", "TR", "RT", "RT", "TR", "TR", "TR","TR", "RT", "RT", "RT", "RT", "TR", "TR", "TR", "TR", "RT", "RT", "RT", "RT", "TR", "TR", "RT", "RT", "RT", "RT", "TR", "TR", "RT", "RT"]),
period = repeat(1:2, 32),
AUC = [7.95472, 7.70976, 7.61332, 7.6009, 7.64492, 7.50988, 7.9338, 7.95997, 7.65539, 7.46394, 7.6039, 7.53956, 7.69712, 7.56786, 7.45934, 7.54009, 7.21229, 7.06902, 7.51643, 7.37901, 7.48156, 7.36834, 7.54856, 7.82564, 7.02909, 6.94312, 8.00537, 7.71289, 7.58731, 7.48324, 7.60788, 7.56941, 7.28207, 7.16781, 7.54961, 7.45588, 7.81157, 7.61234, 7.47477, 7.29438, 7.42536, 7.19744, 7.36771, 7.52564, 8.29505, 7.80344, 7.72798, 7.77863, 7.59388, 7.52672, 7.5725, 7.37337, 7.06902, 7.04491, 7.83162, 7.57096, 7.43603, 7.4961, 7.45991, 7.41156, 7.35244, 7.39572, 7.62071, 7.69576])
data.formulation = categorical(getindex.(data.sequence, data.period))
categorical!(data, :period)
model = fit(LinearMixedModel,
@formula(AUC ~ formulation + sequence + period + (1|subject)),
data,
contrasts = Dict(:period => EffectsCoding()))