Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/linearmixedmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ LinearMixedModel(f::FormulaTerm, tbl;
function LinearMixedModel(f::FormulaTerm, tbl::Tables.ColumnTable;
contrasts = Dict{Symbol,Any}(),
wts = [])

form = apply_schema(f, schema(f, tbl, contrasts), LinearMixedModel)
tbl, _ = StatsModels.missing_omit(tbl, form)

y, Xs = modelcols(form, tbl)

y = reshape(float(y), (:, 1)) # y as a floating-point matrix
Expand Down
4 changes: 4 additions & 0 deletions src/randomeffectsterm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ end
Base.show(io::IO, t::RandomEffectsTerm) = print(io, "($(t.lhs) | $(t.rhs))")
StatsModels.is_matrix_term(::Type{RandomEffectsTerm}) = false

function StatsModels.termvars(t::RandomEffectsTerm)
vcat(StatsModels.termvars(t.lhs), StatsModels.termvars(t.rhs))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to say you might want to use union (like StatsModels does) but there shouldn't be any duplication between the lhs and rhs so there's really no need.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, duplication on the lhs and rhs would be very bad.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be worth checking that in the constructor actually...

end

function StatsModels.apply_schema(t::FunctionTerm{typeof(|)}, schema::StatsModels.FullRank,
Mod::Type{<:MixedModel})
lhs, rhs = apply_schema.(t.args_parsed, Ref(schema), Mod)
Expand Down