[Lme4-commits] r1746 - in pkg/lme4: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed May 16 23:38:20 CEST 2012


Author: dmbates
Date: 2012-05-16 23:38:20 +0200 (Wed, 16 May 2012)
New Revision: 1746

Modified:
   pkg/lme4/R/lmer.R
   pkg/lme4/R/profile.R
   pkg/lme4/man/glmer.Rd
   pkg/lme4/man/profile-methods.Rd
   pkg/lme4/man/refit.Rd
Log:
Patches on some help files through the roxygen sources.


Modified: pkg/lme4/R/lmer.R
===================================================================
--- pkg/lme4/R/lmer.R	2012-05-16 21:37:42 UTC (rev 1745)
+++ pkg/lme4/R/lmer.R	2012-05-16 21:38:20 UTC (rev 1746)
@@ -242,19 +242,22 @@
 ##' @examples
 ##' ## generalized linear mixed model
 ##' library(lattice)
-##' xyplot(incidence/size ~ period, group=herd, type="a", data=cbpp)
+##' xyplot(incidence/size ~ period|herd, cbpp, type=c('g','p','l'),
+##'        layout=c(3,5), index.cond = function(x,y)max(y))
 ##' (gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
 ##'               data = cbpp, family = binomial))
 ##' ## using nAGQ=0 only gets close to the optimum
 ##' (gm1a <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
 ##'                cbpp, binomial, nAGQ = 0))
-##' if(FALSE) { ##________ FIXME _______
 ##' ## using  nAGQ = 9  provides a better evaluation of the deviance
+##' ## Currently the internal calculations use the sum of deviance residuals,
+##' ## which is not directly comparable with the nAGQ=0 or nAGQ=1 result.
 ##' (gm1a <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
 ##'                cbpp, binomial, nAGQ = 9))
-##' }#__ end{FIXME} __
-##'
+##' 
 ##' ## GLMM with individual-level variability (accounting for overdispersion)
+##' ## For this data set the model is the same as one allowing for a period:herd
+##' ## interaction, which the plot indicates could be needed.
 ##' cbpp$obs <- 1:nrow(cbpp)
 ##' (gm2 <- glmer(cbind(incidence, size - incidence) ~ period +
 ##'     (1 | herd) +  (1|obs),
@@ -458,6 +461,20 @@
     mkMerMod(environment(devfun), opt, vals$reTrms, vals$frame, mc)
 }## {nlmer}
 
+## global variables defs to make codetools/R CMD check happier.
+## FIXME: does putting globalVariables() stuff here interfere with Roxygen?
+## ?globalVariables says that fields and methods in reference classes are
+## "handled automatically by ‘setRefClass()’ and friends, using the
+##  supplied field and method names" -- perhaps there's a better way to do this?
+if (getRversion()<="2.15.0")  {
+    ## dummy
+    globalVariables <- function(...) {}
+}
+globalVariables(c("pp","resp","lp0","pwrssUpdate","compDev",
+                  "baseOffset","GQmat","fac","nlmerAGQ","tolPwrss",
+                  "dpars","verbose"),
+                package="lme4")
+
 ##' Create a deviance evaluation function from a predictor and a response module
 ##'
 ##' From an merMod object create an R function that takes a single argument,
@@ -488,20 +505,6 @@
 ##' (dd <- lmer(Yield ~ 1|Batch, Dyestuff, devFunOnly=TRUE))
 ##' dd(0.8)
 ##' minqa::bobyqa(1, dd, 0)
-
-## global variables defs to make codetools/R CMD check happier.
-## FIXME: does putting globalVariables() stuff here interfere with Roxygen?
-## ?globalVariables says that fields and methods in reference classes are
-## "handled automatically by ‘setRefClass()’ and friends, using the
-##  supplied field and method names" -- perhaps there's a better way to do this?
-if (getRversion()<="2.15.0")  {
-    ## dummy
-    globalVariables <- function(...) {}
-}
-globalVariables(c("pp","resp","lp0","pwrssUpdate","compDev",
-                   "baseOffset","GQmat","fac","nlmerAGQ","tolPwrss",
-                   "dpars","verbose"),
-                 package="lme4")
 mkdevfun <- function(rho, nAGQ=1L) {
     ## FIXME: should nAGQ be automatically embedded in rho?
     stopifnot(is.environment(rho), is(rho$resp, "lmResp"))
@@ -917,8 +920,7 @@
 }
 
 ##' @importFrom stats formula
-##' @S3method fixef merMod
-##' @export
+##' @S3method formula merMod
 formula.merMod <- function(x, fixed.only=FALSE, ...) {
     form <- formula(getCall(x),...)
     if (fixed.only) {

Modified: pkg/lme4/R/profile.R
===================================================================
--- pkg/lme4/R/profile.R	2012-05-16 21:37:42 UTC (rev 1745)
+++ pkg/lme4/R/profile.R	2012-05-16 21:38:20 UTC (rev 1746)
@@ -27,10 +27,12 @@
 ##' @examples
 ##' fm01ML <- lmer(Yield ~ 1|Batch, Dyestuff, REML = FALSE)
 ##' ## 0.8s (on a 5600 MIPS 64bit fast(year 2009) desktop "AMD Phenom(tm) II X4 925"):
-##' system.time( tpr <- profile(fm01ML) )
+##' ## This is slower because of the Nelder-Mead optimizer but using bobyqa, the default,
+##' ## produces a warning.
+##' system.time( tpr <- profile(fm01ML, optimizer="Nelder_Mead") )
 ##' (confint(tpr) -> CIpr)
 ##' print(xyplot(tpr))
-##' tpr2 <- profile(fm01ML, which=1:2) ## Batch and residual variance only
+##' tpr2 <- profile(fm01ML, which=1:2, optimizer="Nelder_Mead") ## Batch and residual variance only
 ##' ## GLMM example (running time ~8 seconds on a modern machine)
 ##' \dontrun{
 ##' gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
@@ -783,13 +785,14 @@
     x
 }
 
-##' Create an approximating density from a profile object
-##'
-##' @title Approximate densities from profiles
-##' @param pr a profile object
-##' @param npts number of points at which to evaluate the density
-##' @param upper upper bound on cumulative for a cutoff
-##' @return a data frame
+## Create an approximating density from a profile object
+##
+## @title Approximate densities from profiles
+## @param pr a profile object
+## @param npts number of points at which to evaluate the density
+## @param upper upper bound on cumulative for a cutoff
+## @return a data frame
+## @export
 dens <- function(pr, npts=201, upper=0.999) {
     stopifnot(inherits(pr, "thpr"))
     npts <- as.integer(npts)

Modified: pkg/lme4/man/glmer.Rd
===================================================================
--- pkg/lme4/man/glmer.Rd	2012-05-16 21:37:42 UTC (rev 1745)
+++ pkg/lme4/man/glmer.Rd	2012-05-16 21:38:20 UTC (rev 1746)
@@ -199,19 +199,22 @@
 \examples{
 ## generalized linear mixed model
 library(lattice)
-xyplot(incidence/size ~ period, group=herd, type="a", data=cbpp)
+xyplot(incidence/size ~ period|herd, cbpp, type=c('g','p','l'),
+       layout=c(3,5), index.cond = function(x,y)max(y))
 (gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
               data = cbpp, family = binomial))
 ## using nAGQ=0 only gets close to the optimum
 (gm1a <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
                cbpp, binomial, nAGQ = 0))
-if(FALSE) { ##________ FIXME _______
 ## using  nAGQ = 9  provides a better evaluation of the deviance
+## Currently the internal calculations use the sum of deviance residuals,
+## which is not directly comparable with the nAGQ=0 or nAGQ=1 result.
 (gm1a <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
                cbpp, binomial, nAGQ = 9))
-}#__ end{FIXME} __
 
 ## GLMM with individual-level variability (accounting for overdispersion)
+## For this data set the model is the same as one allowing for a period:herd
+## interaction, which the plot indicates could be needed.
 cbpp$obs <- 1:nrow(cbpp)
 (gm2 <- glmer(cbind(incidence, size - incidence) ~ period +
     (1 | herd) +  (1|obs),

Modified: pkg/lme4/man/profile-methods.Rd
===================================================================
--- pkg/lme4/man/profile-methods.Rd	2012-05-16 21:37:42 UTC (rev 1745)
+++ pkg/lme4/man/profile-methods.Rd	2012-05-16 21:38:20 UTC (rev 1746)
@@ -2,7 +2,6 @@
 \name{profile-methods}
 \alias{profile.merMod}
 \alias{profile-methods}
-\alias{as.data.frame.thpr}
 \title{Methods for profile() of [ng]lmer fitted models}
 \usage{
   \method{profile}{merMod} (fitted, which = 1:nptot,
@@ -63,10 +62,12 @@
 \examples{
 fm01ML <- lmer(Yield ~ 1|Batch, Dyestuff, REML = FALSE)
 ## 0.8s (on a 5600 MIPS 64bit fast(year 2009) desktop "AMD Phenom(tm) II X4 925"):
-system.time( tpr <- profile(fm01ML) )
+## This is slower because of the Nelder-Mead optimizer but using bobyqa, the default,
+## produces a warning.
+system.time( tpr <- profile(fm01ML, optimizer="Nelder_Mead") )
 (confint(tpr) -> CIpr)
 print(xyplot(tpr))
-tpr2 <- profile(fm01ML, which=1:2) ## Batch and residual variance only
+tpr2 <- profile(fm01ML, which=1:2, optimizer="Nelder_Mead") ## Batch and residual variance only
 ## GLMM example (running time ~8 seconds on a modern machine)
 \dontrun{
 gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),

Modified: pkg/lme4/man/refit.Rd
===================================================================
--- pkg/lme4/man/refit.Rd	2012-05-16 21:37:42 UTC (rev 1745)
+++ pkg/lme4/man/refit.Rd	2012-05-16 21:38:20 UTC (rev 1746)
@@ -29,14 +29,4 @@
   creation of the model representation and goes directly to
   the optimization step.
 }
-\examples{
-  ## using refit() to fit each column in a matrix of responses
-  set.seed(101)
-  Y <- matrix(rnorm(1000),ncol=10)
-  res <- list()
-  d <- data.frame(y=Y[,1],x=rnorm(100),f=rep(1:10,10))
-  fit1 <- lmer(y~x+(1|f),data=d)
-  res <- c(fit1,lapply(as.data.frame(Y[,-1]),
-          refit,object=fit1))
-}
-  
\ No newline at end of file
+



More information about the Lme4-commits mailing list