Public Documentation
Documentation for MixedModels.jl
's public interface.
See Internal Documentation for internal package docs covering all submodules.
Contents
Index
Base.LinAlg.cond
MixedModels.LaplaceDeviance
MixedModels.LinearMixedModel
MixedModels.ScalarReMat
MixedModels.VarCorr
MixedModels.VectorReMat
MixedModels.bootstrap
MixedModels.fixef
MixedModels.lmm
MixedModels.lowerbd
MixedModels.objective
MixedModels.pirls!
MixedModels.pwrss
MixedModels.ranef
MixedModels.refit!
MixedModels.remat
MixedModels.sdest
MixedModels.simulate!
MixedModels.varest
StatsBase.coef
StatsBase.coeftable
StatsBase.deviance
StatsBase.df
StatsBase.fit!
StatsBase.fitted
StatsBase.model_response
StatsBase.nobs
StatsBase.vcov
MixedModels
#
MixedModels.LinearMixedModel
— Type.
LinearMixedModel
Linear mixed-effects model representation
Members:
mf
: the model frame, mostly used to get theterms
component for labelling fixed effectswttrms
: a lengthnt
vector of weighted model matrices. The last two elements areX
andy
.trms
: a vector of unweighted model matrices. Ifisempty(sqrtwts)
the same object aswttrms
Λ
: a lengthnt - 2
vector of lower triangular matricessqrtwts
: a lengthn
vector of weightsA
: annt × nt
symmetric matrix of matrices representinghcat(Z,X,y)'hcat(Z,X,y)
R
: ant × nt
matrix of matrices - the upper Cholesky factor ofΛ'AΛ+I
opt
: anOptSummary
object
#
MixedModels.ScalarReMat
— Type.
ScalarReMat
The representation of the model matrix for a scalar random-effects term
Members:
f
: the grouping factor as aPooledDataVector
z
: the raw random-effects model matrix as aVector
fnm
: the name of the grouping factor as aSymbol
cnms
: aVector
of column names
#
MixedModels.VarCorr
— Type.
VarCorr
An encapsulation of information on the fitted random-effects variance-covariance matrices.
Members:
Λ
: the vector of lower triangular matrices from theMixedModel
fnms
: aVector{ASCIIString}
of grouping factor namescnms
: aVector{Vector{ASCIIString}}
of column namess
: the estimate of σ, the standard deviation of the per-observation noise
The main purpose is to isolate the logic in the show method.
#
MixedModels.VectorReMat
— Type.
VectorReMat
The representation of the model matrix for a vector-valued random-effects term
Members:
f
: the grouping factor as aPooledDataVector
z
: the transposed raw random-effects model matrixfnm
: the name of the grouping factor as aSymbol
cnms
: aVector
of column names (row names after transposition) ofz
#
MixedModels.bootstrap
— Function.
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
: aLinearMixedModel
that has been fit.N
: the number of bootstrap samples to simulatesavresults
: a function with argumentsi
andm
called after each bootstrap simulation. As the name indicates, this function should save the results of interest.
#
StatsBase.coef
— Method.
nothing
#
StatsBase.coeftable
— Method.
nothing
#
Base.LinAlg.cond
— Method.
cond(m::MixedModel)
Args:
m
: aMixedModel
Returns: A Vector
of the condition numbers of the blocks of m.Λ
#
StatsBase.df
— Method.
df(m)
Args:
m
: aLinearMixedModel
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.deviance
— Method.
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
: aLinearMixedModel
verbose
:Bool
indicating if information on iterations should be printed, Defaults tofalse
Named Args:
optimizer
:Symbol
form of the name of a derivative-free optimizer inNLopt
that allows for box constraints. Defaults to:LN_BOBYQA
#
StatsBase.fitted
— Method.
nothing
#
MixedModels.fixef
— Function.
fixef(m)
Args:
m
: aLinearMixedModel
Returns: A Vector
of estimates of the fixed-effects parameters of m
#
MixedModels.LaplaceDeviance
— Function.
LaplaceDeviance(m)
Laplace approximation to the deviance of a GLMM
Args:
m
: aGeneralizedLinearMixedModel
Returns: the Laplace approximation to the deviance of m
#
MixedModels.lmm
— Function.
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
: aMixedModel
Returns: A LinearMixedModel
, either m
itself or the LMM
member of m
lmm(form, frm) lmm(form, frm; weights = wts)
Args:
form
: aDataFrames:Formula
containing fixed-effects and random-effects termsfrm
: aDataFrame
in which to evaluateform
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.lowerbd
— Function.
lowerbd(m)
Args:
m
: aMixedModel
Returns: A Vector
of lower bounds on the covariance parameter vector m[:θ]
lower bounds on the parameters (elements in the lower triangle)
#
StatsBase.model_response
— Method.
extract the response (as a reference)
#
StatsBase.nobs
— Method.
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.objective
— Function.
objective(m)
Args:
m
: aLinearMixedModel
object
Returns: Negative twice the log-likelihood of model m
#
MixedModels.pwrss
— Function.
pwrss(m::LinearMixedModel)
Args:
m
: aLinearMixedModel
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
: aGeneralizedLinearMixedModel
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.ranef
— Function.
ranef(m) ranef(m, uscale)
Conditional modes of the random effects in model m
Args:
m
: a fittedMixedModel
objectuscale
: aBool
indicating conditional modes are on theu
scale or theb
scale. Defaults tofalse
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
: aMixedModel{T}
y
: aVector{T}
of lengthn
, the number of observations inm
Returns: m
after refitting
#
MixedModels.remat
— Function.
remat(e,df)
A factory for ReMat
objects
Args:
e
: anExpr
which should be of the form:(e1 | e2)
wheree1
is a valid rhs of aFormula
andpool(e2)
can be evaluated.df
: aDataFrame
in which to evaluatee1
ande2
Returns: a ScalarReMat
or a VectorReMat
, as appropriate.
#
MixedModels.sdest
— Function.
sdest(m)
Args:
m
: aLinearMixedModel
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
: aLinearMixedModel
.β
: the fixed-effects parameter vector to use; defaults tocoef(m)
σ
: the standard deviation of the per-observation random noise term to use; defaults tosdest(m)
θ
: the covariance parameter vector to use; defaults tom[:θ]
Returns: m
after having refit it to the simulated response vector
#
MixedModels.varest
— Function.
varest(m::LinearMixedModel)
Args:
m
: aLinearMixedModel
Returns: The scalar, s², the estimate of σ², the variance of the conditional distribution of Y given B
#
StatsBase.vcov
— Function.
vcov(m)
Estimated covariance matrix of the fixed-effects estimator
Args:
m
: aLinearMixedModel
Returns a p × p
Matrix