[Lme4-commits] r1664 - in pkg/lme4: R man tests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Mar 16 14:48:48 CET 2012
Author: bbolker
Date: 2012-03-16 14:48:48 +0100 (Fri, 16 Mar 2012)
New Revision: 1664
Added:
pkg/lme4/tests/resids.R
Modified:
pkg/lme4/R/lmer.R
pkg/lme4/R/profile.R
pkg/lme4/man/mcmcsamp.Rd
pkg/lme4/man/profile-methods.Rd
Log:
do-roxy based updates (missing arguments, although still incomplete)
fix/test residuals, especially Pearson resids from GLMMs
Modified: pkg/lme4/R/lmer.R
===================================================================
--- pkg/lme4/R/lmer.R 2012-03-15 21:23:34 UTC (rev 1663)
+++ pkg/lme4/R/lmer.R 2012-03-16 13:48:48 UTC (rev 1664)
@@ -1131,6 +1131,7 @@
partial = .NotYetImplemented())
}
+## FIXME: document somewhere that residuals(glmerfit) returns deviance residuals by default
##' @S3method residuals glmResp
residuals.glmResp <- function(object, type = c("deviance", "pearson",
"working", "response", "partial"),
@@ -1144,7 +1145,7 @@
d.res <- sqrt(object$devResid())
ifelse(y > mu, d.res, -d.res)
},
- pearson = object$wtres(),
+ pearson = object$wtres,
working = object$wrkResids(),
response = y - mu,
partial = .NotYetImplemented())
Modified: pkg/lme4/R/profile.R
===================================================================
--- pkg/lme4/R/profile.R 2012-03-15 21:23:34 UTC (rev 1663)
+++ pkg/lme4/R/profile.R 2012-03-16 13:48:48 UTC (rev 1664)
@@ -13,6 +13,8 @@
##' @param delta stepping scale for deciding on next point to profile
##' @param verbose level of output from internal calculations
##' @param devtol tolerance for fitted deviances less than baseline (supposedly minimum) deviance
+##' @param startval method for picking starting conditions for optimization (STUB)
+##' @param optimizer (character or function) optimizer to use (see \code{\link{lmer}} for details)
##' @param \dots potential further arguments for \code{profile} methods.
##' @section Methods: FIXME: These (signatures) will change soon --- document
##' \bold{after} change!
Modified: pkg/lme4/man/mcmcsamp.Rd
===================================================================
--- pkg/lme4/man/mcmcsamp.Rd 2012-03-15 21:23:34 UTC (rev 1663)
+++ pkg/lme4/man/mcmcsamp.Rd 2012-03-16 13:48:48 UTC (rev 1664)
@@ -1,18 +1,18 @@
\name{mcmcsamp}
\alias{mcmcsamp}
-\title{Create an McMC sample}
+\title{Create an MCMC sample}
\usage{
mcmcsamp(object, n = 1L, verbose = FALSE, ...)
}
\arguments{
\item{object}{a fitted model object}
- \item{n}{number of samples to generate. Defaults to 1
- but that value doesn't make sense.}
+ \item{n}{number of samples to generate. Defaults to 1;
+ for real use values of 200-1000 are more typical}
\item{verbose}{should verbose output be given?}
- \item{...}{}
+ \item{...}{additional, optional arguments (not used)}
}
\value{
a Markov chain Monte Carlo sample as a matrix
Modified: pkg/lme4/man/profile-methods.Rd
===================================================================
--- pkg/lme4/man/profile-methods.Rd 2012-03-15 21:23:34 UTC (rev 1663)
+++ pkg/lme4/man/profile-methods.Rd 2012-03-16 13:48:48 UTC (rev 1664)
@@ -30,6 +30,12 @@
\item{devtol}{tolerance for fitted deviances less than
baseline (supposedly minimum) deviance}
+ \item{startval}{method for picking starting conditions
+ for optimization (STUB)}
+
+ \item{optimizer}{(character or function) optimizer to use
+ (see \code{\link{lmer}} for details)}
+
\item{\dots}{potential further arguments for
\code{profile} methods.}
}
Added: pkg/lme4/tests/resids.R
===================================================================
--- pkg/lme4/tests/resids.R (rev 0)
+++ pkg/lme4/tests/resids.R 2012-03-16 13:48:48 UTC (rev 1664)
@@ -0,0 +1,18 @@
+library(lme4)
+
+## raw residuals for LMMs
+fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
+stopifnot(all.equal(residuals(fm1),sleepstudy$Reaction-fitted(fm1)))
+
+r1 <- residuals(fm1,type="pearson")
+
+## deviance/Pearson residuals for GLMMs
+gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
+ family = binomial, data = cbpp)
+p <- fitted(gm1)
+n <- cbpp$size
+v <- n*p*(1-p)
+obs_p <- cbpp$incidence/cbpp$size
+stopifnot(all.equal(residuals(gm1,"pearson"),(obs_p-p)/sqrt(p*(1-p))*n))
+
+r2 <- residuals(gm1,type="deviance")
More information about the Lme4-commits
mailing list