r - Extractor Functions in lme4 Misfunctioning? -
i'm trying understand linear algebra operations behind lmer function in r, , found seemed great resource on-line on lecture given creator of lme4 package, douglas bates.
the example deals dataset dyestuff , calls mixed-effects model follows:
fm1 <- lmer(yield ~ 1 + (1 | batch), dyestuff) the following slides include lines of code extract underlying matrices random effects, such as:
efm1 <- expand(fm1) efm1$s 6 x 6 diagonal matrix of class "ddimatrix" # [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.84823 . . . . . [2,] . 0.84823 . . . . [3,] . . 0.84823 . . . [4,] . . . 0.84823 . . [5,] . . . . 0.84823 . [6,] . . . . . 0.84823 and,
efm1$t6 x 6 sparse matrix of class "dtcmatrix" [1,] 1 . . . . . [2,] . 1 . . . . [3,] . . 1 . . . [4,] . . . 1 . . [5,] . . . . 1 . [6,] . . . . . 1 or,
(fm1s <- tcrossprod(efm1$t %*% efm1$s)) 6 x 6 sparse matrix of class "dscmatrix" [1,] 0.71949 . . . . . [2,] . 0.71949 . . . . [3,] . . 0.71949 . . . [4,] . . . 0.71949 . . [5,] . . . . 0.71949 . [6,] . . . . . 0.71949 yet, when try run same line codes on r, following error messages:
efm1 <- expand(fm1) error in (function (classes, fdef, mtable) : unable find inherited method function ‘expand’ signature ‘"lmermod"’ and not surprisingly,
efm1$s error: object 'efm1' not found doing ?expand identifies function still existing, , seemingly meant produce matrix decompositions, such lu or rq.
doing search on-line, found out douglas using julia (can next statistical language have less implausible name? no, not "pied pier"! sorry, digress...).
what doing wrong? lme4 orphan , in decay? there typo in slides?
you're looking @ old slides.
- a full description of linear mixed model capabilities of package, including details of internal representation, on arxiv, in press in j. stat. software (a reference information in citation information package on cran). (we're still working on paper describes glmm capabilities.)
- the
getme()function current recommended method accessing model information. lme4still under active development on github.- doug bates indeed more interested in building mixed model frameworks in julia now, still participates in
lme4maintenance extent.
the notation/internal representation has changed somewhat, reconstructing variance-covariance matrix internal information can done follows (the internal lambdat equivalent t(t %*% s) in old notation).
library("lme4") fm1 <- lmer(yield ~ 1 + (1 | batch), dyestuff) crossprod(getme(fm1,"lambdat"))
Comments
Post a Comment