[R-sig-ME] equivalent of lme4::rePCA() for lme models
Simon Harmel
@|m@h@rme| @end|ng |rom gm@||@com
Tue Feb 2 18:08:25 CET 2021
Thanks, Phillip!
On Tue, Feb 2, 2021 at 7:00 AM Phillip Alday <me using phillipalday.com> wrote:
> No, but you can implement it yourself; it's literally just the PCA/SVD
> of the random-effects matrices:
>
> > lme4:::rePCA.merMod
> function (x)
> {
> chfs <- getME(x, "Tlist")
> nms <- names(chfs)
> unms <- unique(nms)
> names(unms) <- unms
> svals <- function(m) { # this is applied each of the RE matrices
> vv <- svd(m, nv = 0L)
> names(vv) <- c("sdev", "rotation")
> vv$center <- FALSE
> vv$scale <- FALSE
> class(vv) <- "prcomp"
> vv
> }
> structure(lapply(unms, function(m)
> svals(Matrix::bdiag(chfs[which(nms ==
> m)]))), class = "prcomplist")
> }
>
> You'll have to look at the nlme documentation to see how those are
> stored internally. I don't remember off the top of my head.
>
> Phillip
>
> On 2/2/21 4:55 am, Simon Harmel wrote:
> > Dear All,
> >
> > I was wondering if there is any `lme4::rePCA()` equivalent for
> > `nlme::lme()` models (a reproducible example is below)?
> >
> > --Thanks, Simon
> >
> > library(nlme)
> >
> > dat <- read.csv('
> https://raw.githubusercontent.com/hkil/m/master/mv.l.csv')
> >
> > m22 <- lme(value ~0 + name, random = ~0 + name| Student, data = dat,
> > correlation = corSymm(), weights = varIdent(form = ~1|name))
> >
> > [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-mixed-models using r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> >
>
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list