Public Documentation

Documentation for MixedModels.jl's public interface.

See Internal Documentation for internal package docs covering all submodules.

Contents

Index

MixedModels

# MixedModels.LinearMixedModelType.


LinearMixedModel

Linear mixed-effects model representation

Members:

  • mf: the model frame, mostly used to get the terms component for labelling fixed effects
  • wttrms: a length nt vector of weighted model matrices. The last two elements are X and y.
  • trms: a vector of unweighted model matrices. If isempty(sqrtwts) the same object as wttrms
  • Λ: a length nt - 2 vector of lower triangular matrices
  • sqrtwts: a length n vector of weights
  • A: an nt × nt symmetric matrix of matrices representing hcat(Z,X,y)'hcat(Z,X,y)
  • R: a nt × nt matrix of matrices - the upper Cholesky factor of Λ'AΛ+I
  • opt: an OptSummary object

# MixedModels.ScalarReMatType.


ScalarReMat

The representation of the model matrix for a scalar random-effects term

Members:

  • f: the grouping factor as a PooledDataVector
  • z: the raw random-effects model matrix as a Vector
  • fnm: the name of the grouping factor as a Symbol
  • cnms: a Vector of column names

# MixedModels.VarCorrType.


VarCorr

An encapsulation of information on the fitted random-effects variance-covariance matrices.

Members:

  • Λ: the vector of lower triangular matrices from the MixedModel
  • fnms: a Vector{ASCIIString} of grouping factor names
  • cnms: a Vector{Vector{ASCIIString}} of column names
  • s: the estimate of σ, the standard deviation of the per-observation noise

The main purpose is to isolate the logic in the show method.

# MixedModels.VectorReMatType.


VectorReMat

The representation of the model matrix for a vector-valued random-effects term

Members:

  • f: the grouping factor as a PooledDataVector
  • z: the transposed raw random-effects model matrix
  • fnm: the name of the grouping factor as a Symbol
  • cnms: a Vector of column names (row names after transposition) of z

# MixedModels.bootstrapFunction.


bootstrap(m, N, saveresults)

Simulate N response vectors from m, refitting the model. The function saveresults is called after each refit.

To save space m.trms[end], which is the response vector, is overwritten by each simulation. The original response is restored before returning.

Args:

  • m: a LinearMixedModel that has been fit.
  • N: the number of bootstrap samples to simulate
  • savresults: a function with arguments i and m called after each bootstrap simulation. As the name indicates, this function should save the results of interest.

# StatsBase.coefMethod.


nothing # StatsBase.coeftableMethod.


nothing # Base.LinAlg.condMethod.


cond(m::MixedModel)

Args:

  • m: a MixedModel

Returns: A Vector of the condition numbers of the blocks of m.Λ

# StatsBase.dfMethod.


df(m)

Args:

  • m: a LinearMixedModel

Returns: Number of parameters in the model.

df(obj::StatisticalModel)

Returns the number of degrees of freedom consumed in the model, including when applicable the intercept and the distribution's dispersion parameter.

# StatsBase.devianceMethod.


deviance(obj::StatisticalModel)

Returns the deviance of the model relative to a reference, which is usually when applicable the saturated model. It is equal, up to a constant, to -2 log L, with L the likelihood of the model.

# StatsBase.fit!Method.


fit!(m[, verbose = false]; optimizer = :LN_BOBYQA)

Optimize the objective of a LinearMixedModel using an NLopt optimizer.

Args:

  • m: a LinearMixedModel
  • verbose: Bool indicating if information on iterations should be printed, Defaults to false

Named Args:

  • optimizer: Symbol form of the name of a derivative-free optimizer in NLopt that allows for box constraints. Defaults to :LN_BOBYQA

# StatsBase.fittedMethod.


nothing # MixedModels.fixefFunction.


fixef(m)

Args:

  • m: a LinearMixedModel

Returns: A Vector of estimates of the fixed-effects parameters of m

# MixedModels.LaplaceDevianceFunction.


LaplaceDeviance(m)

Laplace approximation to the deviance of a GLMM

Args:

  • m: a GeneralizedLinearMixedModel

Returns: the Laplace approximation to the deviance of m

# MixedModels.lmmFunction.


lmm(m::MixedModel)

Extract the LinearMixedModel from a MixedModel. If m is itself a LinearMixedModel this simply returns m. If m is a GeneralizedLinearMixedModel this returns its LMM member.

Args:

  • m: a MixedModel

Returns: A LinearMixedModel, either m itself or the LMM member of m

lmm(form, frm)
lmm(form, frm; weights = wts)

Args:

  • form: a DataFrames:Formula containing fixed-effects and random-effects terms
  • frm: a DataFrame in which to evaluate form
  • weights: an optional vector of prior weights in the model. Defaults to unit weights.

Returns: A LinearMixedModel.

Notes: The return value is ready to be fit! but has not yet been fit.

# MixedModels.lowerbdFunction.


lowerbd(m)

Args:

  • m: a MixedModel

Returns: A Vector of lower bounds on the covariance parameter vector m[:θ]

lower bounds on the parameters (elements in the lower triangle)

# StatsBase.model_responseMethod.


extract the response (as a reference)

# StatsBase.nobsMethod.


nobs(obj::StatisticalModel)

Returns the number of independent observations on which the model was fitted. Be careful when using this information, as the definition of an independent observation may vary depending on the model, on the format used to pass the data, on the sampling plan (if specified), etc.

# MixedModels.objectiveFunction.


objective(m)

Args:

  • m: a LinearMixedModel object

Returns: Negative twice the log-likelihood of model m

# MixedModels.pwrssFunction.


pwrss(m::LinearMixedModel)

Args:

  • m: a LinearMixedModel

Returns: The penalized residual sum-of-squares, a scalar.

# MixedModels.pirls!Function.


pirls!(m)

Use Penalized Iteratively Reweighted Least Squares (PIRLS) to determine the conditional modes of the random effects

Args:

  • m: a GeneralizedLinearMixedModel

Returns: the updated model m

Note: On entry the values of m.u₀ and m.devold should correspond. One safe approach is to zero out m.u₀ and evaluate devold from fixed-effects only.

# MixedModels.ranefFunction.


ranef(m)
ranef(m, uscale)

Conditional modes of the random effects in model m

Args:

  • m: a fitted MixedModel object
  • uscale: a Bool indicating conditional modes are on the u scale or the b scale. Defaults to false

Returns: A Vector of matrices of the conditional modes of the random effects on the indicated scale. For a scalar random-effects term the matrix is 1 × k where k is the number of levels of the grouping factor. For a vector-valued random-effects term the matrix is l × k where l is the dimension of each random effect.

# MixedModels.refit!Function.


refit!(m, y)

Refit the model m with response y

Args:

  • m: a MixedModel{T}
  • y: a Vector{T} of length n, the number of observations in m

Returns: m after refitting

# MixedModels.rematFunction.


 remat(e,df)

A factory for ReMat objects

Args:

  • e: an Expr which should be of the form :(e1 | e2) where e1 is a valid rhs of a Formula and pool(e2) can be evaluated.
  • df: a DataFrame in which to evaluate e1 and e2

Returns: a ScalarReMat or a VectorReMat, as appropriate.

# MixedModels.sdestFunction.


sdest(m)

Args:

  • m: a LinearMixedModel object

Returns: The scalar, s, the estimate of σ, the standard deviation of the per-observation noise

# MixedModels.simulate!Function.


simulate!(m; β, σ, θ)

Simulate a response vector from model m, and refit m.

Args:

  • m: a LinearMixedModel.
  • β: the fixed-effects parameter vector to use; defaults to coef(m)
  • σ: the standard deviation of the per-observation random noise term to use; defaults to sdest(m)
  • θ: the covariance parameter vector to use; defaults to m[:θ]

Returns: m after having refit it to the simulated response vector

# MixedModels.varestFunction.


varest(m::LinearMixedModel)

Args:

  • m: a LinearMixedModel

Returns: The scalar, s², the estimate of σ², the variance of the conditional distribution of Y given B

# StatsBase.vcovFunction.


 vcov(m)

Estimated covariance matrix of the fixed-effects estimator

Args:

  • m: a LinearMixedModel

Returns a p × p Matrix