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

Potential bug in fit(Type, formula, data, contrasts = d, ...) #78

Closed
Nosferican opened this issue Dec 24, 2018 · 2 comments
Closed

Potential bug in fit(Type, formula, data, contrasts = d, ...) #78

Nosferican opened this issue Dec 24, 2018 · 2 comments

Comments

@Nosferican
Copy link
Contributor

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.

@andreasnoack
Copy link
Member

Please provide a complete example.

@Nosferican
Copy link
Contributor Author

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()))

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

No branches or pull requests

3 participants