Consider a linear mixed model with normal random effects, [REMOVE_ME]Yij=XijTβ+vi+ϵij[REMOVEME2]
where i=1,…,n,j=1,…,m, or it can be equivalently expressed using matrix notation, [REMOVE_ME]Y=Xβ+Zv+ϵ[REMOVEME2]
where Y∈Rnm is a known vector of observations, X∈Rnm×p and Z∈Rnm×n design matrices for β and v respectively, β∈Rp and v∈Rn unknown vectors of fixed effects and random effects where vi∼N(0,λi), and ϵ∈Rnm an unknown vector random errors independent of random effects. Note that Z
does not need to be provided by a user since it is automatically created accordingly to the problem specification.
SolveHMME(X, Y, Mu, Lambda)
Arguments
X: an (nm×p) design matrix for β.
Y: a length-nm vector of observations.
Mu: a length-nm vector of initial values for μi=E(Yi).
Lambda: a length-n vector of initial values for λ, variance of vi∼N(0,λi)
Returns
a named list containing
beta: a length-p vector of BLUE beta^.
v: a length-n vector of BLUP v^.
leverage: a length-(mn+n) vector of leverages.
Description
Consider a linear mixed model with normal random effects,
Yij=XijTβ+vi+ϵij
where i=1,…,n,j=1,…,m, or it can be equivalently expressed using matrix notation,
Y=Xβ+Zv+ϵ
where Y∈Rnm is a known vector of observations, X∈Rnm×p and Z∈Rnm×n design matrices for β and v respectively, β∈Rp and v∈Rn unknown vectors of fixed effects and random effects where vi∼N(0,λi), and ϵ∈Rnm an unknown vector random errors independent of random effects. Note that Z
does not need to be provided by a user since it is automatically created accordingly to the problem specification.
Examples
## small setting for data generationn =100; m =2; p =2nm = n*m; nmp = n*m*p
## generate artifical dataX = matrix(rnorm(nmp,2,1), nm,p)# design matrixY = rnorm(nm,2,1)# observationMu = rep(1, times=nm)Lambda = rep(1, times=n)## solveans = SolveHMME(X, Y, Mu, Lambda)