[Lme4-commits] r1686 - in pkg: lme4/R lme4/man lme4.0/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Mar 22 04:18:02 CET 2012


Author: bbolker
Date: 2012-03-22 04:18:02 +0100 (Thu, 22 Mar 2012)
New Revision: 1686

Modified:
   pkg/lme4.0/R/lmer.R
   pkg/lme4/R/lmer.R
   pkg/lme4/man/getME.Rd
Log:

  added "A" and "flist" to getME()



Modified: pkg/lme4/R/lmer.R
===================================================================
--- pkg/lme4/R/lmer.R	2012-03-20 13:18:30 UTC (rev 1685)
+++ pkg/lme4/R/lmer.R	2012-03-22 03:18:02 UTC (rev 1686)
@@ -1307,9 +1307,6 @@
 ##' @S3method terms merMod
 terms.merMod <- function(x, fixed.only=TRUE, ...) {
   if (fixed.only) {
-      ## do need to drop LHS (e.g. binomial example)
-      ## mm <- model.frame(formula(x,fixed.only=TRUE)[-2],data=model.frame(x))
-      ## terms(mm)
       terms.formula(formula(x,fixed.only=TRUE))
   } else attr(x at frame,"terms")
 }
@@ -1479,9 +1476,14 @@
 ##'     \item{Lambdat}{transpose of the relative covariance factor of the random effects.}
 ##'     \item{Lind}{index vector for inserting elements of \eqn{\theta}{theta} into the
 ##'                 nonzeros of \eqn{\Lambda}{Lambda}}
+##'     \item{A}{Scaled sparse model matrix (class
+##'      \code{"\link[Matrix:dgCMatrix-class]{dgCMatrix}"}) for
+##'      the unit, orthogonal random effects, \eqn{U},
+##'       equal to \code{getME(.,"Zt") \%*\% getME(.,"Lambdat")}}
 ##'     \item{RX}{Cholesky factor for the fixed-effects parameters}
 ##'     \item{RZX}{cross-term in the full Cholesky factor}
-##'     \item{beta}{fixed-effects parameter estimates (same as the result of \code{\link{fixef}})}
+##'     \item{flist}{a list of the grouping variables (factors) involved in the random effect terms}
+##'     \item{beta}{fixed-effects parameter estimates (identical to the result of \code{\link{fixef}}, but without names)}
 ##'     \item{theta}{random-effects parameter estimates: these are parameterized as the relative Cholesky factors of each random effect term}
 ##'     \item{n_rtrms}{number of random-effects terms}
 ##'     \item{is_REML}{same as the result of \code{\link{isREML}}}
@@ -1515,8 +1517,9 @@
 getME <- function(object,
 		  name = c("X", "Z","Zt", "u",
 		  "Gp",
-		  "L", "Lambda", "Lambdat", "Lind",
+		  "L", "Lambda", "Lambdat", "Lind", "A",
 		  "RX", "RZX",
+                  "flist",
                   "beta", "theta",
 		  "REML", "n_rtrms", "is_REML", "devcomp",
                     "offset", "lower"))
@@ -1538,6 +1541,7 @@
 	   "L"= PR$ L(),
 	   "Lambda"= t(PR$ Lambdat),
 	   "Lambdat"= PR$ Lambdat,
+           "A" = PR$Lambdat %*% PR$Zt,
            "Lind" = PR$ Lind,
 	   "RX" = PR $ RX(), ## FIXME - add the column names and row names, either in the C++ or the R method
 	   "RZX" = PR $ RZX, ## FIXME - add column names

Modified: pkg/lme4/man/getME.Rd
===================================================================
--- pkg/lme4/man/getME.Rd	2012-03-20 13:18:30 UTC (rev 1685)
+++ pkg/lme4/man/getME.Rd	2012-03-22 03:18:02 UTC (rev 1686)
@@ -5,7 +5,7 @@
 \title{Extract or Get Generalize Components from a Fitted Mixed Effects Model}
 \usage{
   getME(object,
-    name = c("X", "Z", "Zt", "u", "Gp", "L", "Lambda", "Lambdat", "Lind", "RX", "RZX", "beta", "theta", "REML", "n_rtrms", "is_REML", "devcomp", "offset", "lower"))
+    name = c("X", "Z", "Zt", "u", "Gp", "L", "Lambda", "Lambdat", "Lind", "A", "RX", "RZX", "flist", "beta", "theta", "REML", "n_rtrms", "is_REML", "devcomp", "offset", "lower"))
 }
 \arguments{
   \item{object}{a fitted mixed-effects model of class
@@ -28,10 +28,17 @@
   covariance factor of the random effects.}
   \item{Lind}{index vector for inserting elements of
   \eqn{\theta}{theta} into the nonzeros of
-  \eqn{\Lambda}{Lambda}} \item{RX}{Cholesky factor for the
-  fixed-effects parameters} \item{RZX}{cross-term in the
-  full Cholesky factor} \item{beta}{fixed-effects parameter
-  estimates (same as the result of \code{\link{fixef}})}
+  \eqn{\Lambda}{Lambda}} \item{A}{Scaled sparse model
+  matrix (class
+  \code{"\link[Matrix:dgCMatrix-class]{dgCMatrix}"}) for
+  the unit, orthogonal random effects, \eqn{U}, equal to
+  \code{getME(.,"Zt") \%*\% getME(.,"Lambdat")}}
+  \item{RX}{Cholesky factor for the fixed-effects
+  parameters} \item{RZX}{cross-term in the full Cholesky
+  factor} \item{flist}{a list of the grouping variables
+  (factors) involved in the random effect terms}
+  \item{beta}{fixed-effects parameter estimates (identical
+  to the result of \code{\link{fixef}}, but without names)}
   \item{theta}{random-effects parameter estimates: these
   are parameterized as the relative Cholesky factors of
   each random effect term} \item{n_rtrms}{number of
@@ -40,7 +47,8 @@
   of a named numeric vector, \dQuote{cmp}, and a named
   integer vector, \dQuote{dims}, describing the fitted
   model} \item{offset}{model offset} \item{lower}{lower
-  bounds on model parameters} ## FIXME: theta only? }}
+  bounds on model parameters (random effects parameters
+  only)} }}
 }
 \value{
   Unspecified, as very much depending on the

Modified: pkg/lme4.0/R/lmer.R
===================================================================
--- pkg/lme4.0/R/lmer.R	2012-03-20 13:18:30 UTC (rev 1685)
+++ pkg/lme4.0/R/lmer.R	2012-03-22 03:18:02 UTC (rev 1686)
@@ -2360,7 +2360,8 @@
 getME <- function(object,
                   name = c("X", "Z","Zt", "u",
                   "Gp",
-                  "L", "Lambda", "Lambdat",
+                  "L", "Lambda", "Lambdat", "A",
+                  "flist",
                   "RX", "RZX",
                   "beta", "theta",
 		  "REML", "n_rtrms", "is_REML"))
@@ -2380,9 +2381,10 @@
            "beta" = unname(object at fixef),
 	   "n_rtrms" = object at dims[["nt"]], ##  = #{random-effect terms in the formula}
 	   "is_REML" = as.logical(object at dims[["REML"]]),
-
-	   "Lambda"=, ## from object at L  ??
-	   "Lambdat"=,
+	   "Lambda"={warning("Lambda is not available in lme4.0"); NA}, ## FIXME??
+	   "Lambdat"={warning("Lambdat is not available in lme4.0"); NA},
+           "A"=object at A,
+           "flist"=object at flist,
            "theta"= {
              mnames <- function(z) {
                v <- colnames(z)



More information about the Lme4-commits mailing list