[Rd] methods not found inside function?
Ben Bolker
bolker at ufl.edu
Sun Nov 30 23:11:10 CET 2008
I am currently attempting to hack the recently
featured profileModels package so that it can
handle models generated by the lme4 (mixed models)
package. I'm getting really confused by different
behavior of summary() before and after loading
the lme4 package, and inside and outside the
profileMethod() function. The basic behavior
is that with lme4 loaded, and "obj" a fitted
object of class "mer" from this package,
summary(obj) calls the S4 method. However, as
soon as I step into the profileMethod() function
from the profileMethod package, summary() on
a copy of the same object that has been passed
to the function no longer calls the S4 method ...
Any explanations/workarounds for this ... ?
cheers
Ben Bolker
## before loading the lme4 package:
> summary
function (object, ...)
UseMethod("summary")
<environment: namespace:base>
## now load lme4:
library(lme4)
gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
family = binomial, data = cbpp)
## examine "summary":
> summary
standardGeneric for "summary" defined from package "base"
function (object, ...)
standardGeneric("summary")
<environment: 0xa2aa760>
Methods may be defined for arguments: object
Use showMethods("summary") for currently available ones.
summary(gm1)
## Generalized linear mixed model fit by the Laplace approximation
## Formula: cbind(incidence, size - incidence) ~ period + (1 | herd)
## Data: cbpp
## etc ...
library(profileModel)
debug(profileModel)
prof1.gm1 <- profileModel(fitted=gm1,
objective=deviance)
## step into the function, and then try:
Browse[1]> summary
function (object, ...)
UseMethod("summary")
<environment: namespace:base>
Browse[1]> summary(gm1)
Length Class Mode
1 mer S4
--
Ben Bolker
Associate professor, Biology Dep't, Univ. of Florida
bolker at ufl.edu / www.zoology.ufl.edu/bolker
GPG key: www.zoology.ufl.edu/bolker/benbolker-publickey.asc
More information about the R-devel
mailing list