API
MixedModelsSerialization.LinearMixedModelSummary
MixedModelsSerialization.MixedModelSummary
MixedModelsSerialization.load_summary
MixedModelsSerialization.save_summary
StatsAPI.modelmatrix
MixedModelsSerialization.LinearMixedModelSummary
— TypeLinearMixedModelSummary{T<:AbstractFloat} <: MixedModelSummary{T}
LinearMixedModelSummary(m::LinearMixedModel)
A "summary" of a LinearMixedModel
with a reduced memory footprint.
This type does not store the model matrices of a LinearMixedModel
and thus will consume far less memory, especially for models with many observations. Instead, the relevant entities for summarizing a model are stored:
- fixed effects coefficients and associated variance-covariance matrix
- random effects covariances
- the θ vector and
OptSummary
used in optimization - (conditional modes and variances are not currently stored)
- the log likelihood
- information about the model and residual degrees of freedom
Using these values, it is possible to provide implementations for many but not all methods in StatsAPI
and MixedModels
.
All field names and associated storage format should be considered private implementation details. Use appropriate methods to e.g. extract the log likelihood or the variance-covariance matrix. Stability of the internal structure is not guaranteed, even between non-breaking releases.
MixedModelsSerialization.MixedModelSummary
— TypeMixedModelSummary{T} <: MixedModel{T}
MixedModelSummary(m::LinearMixedModel)
Abstract type for a "summary" of a MixedModel
with a reduced memory footprint.
Concrete subtypes do not the model matrices of a MixedModel
and thus will consume far less memory, especially for models with many observations. However, they may store relevant parameters and derived values for implementing common StatsAPI
` methods that don't depend on the original data.
See also LinearMixedModelSummary
MixedModelsSerialization.load_summary
— Methodload_summary(filename)
Deserialize a MixedModelSummary
from filename
.
MixedModelsSerialization.save_summary
— Methodsave_summary(filename, summary::MixedModelSummary)
Serialize a MixedModelSummary
to filename
.
StatsAPI.modelmatrix
— MethodStatsAPI.modelmatrix(mms::MixedModelSummary)
Return a "summary" model matrix (of the fixed effects).
The summary model matrix is generated so:
- Find reference values for all categorical and continuous terms. For categorical terms these are the levels. For continuous terms, these are the min, mean and max from the original data used to build the model.
- Compute a fake dataset consisting of the Cartesian product of all these variables, i.e. a fully crossed design using the reference values.
- Call
modelcols
using the fixed effects terms and the fake dataset.
The purpose of this fake model matrix is to support packages like Effects.jl. For continuous predictors,the the min, mean, and max are preserved, so these aregood typical values. For categorical predictors, the balance is not preserved, so a good default typical value is mean
, i.e. the unweighted average of all levels. Of course, you can always specify the relevant reference values and avoid the typical values computation for a given term.
This is not the model matrix of the original model.
The balance of levels of categorical terms from the original model is not preserved.
There is currently no support for interaction terms without a corresponding main effect.