[Rd] Namespace/method oddity
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Feb 12 19:43:05 CET 2008
On Tue, 12 Feb 2008, Peter Dalgaard wrote:
> I stumbled on the following:
>
>> library(stats4)
>> example(mle)
>> confint.default(fit2)
> Error in UseMethod("vcov") : no applicable method for "vcov"
> In addition: Warning message:
> In object$coefficients :
> $ operator not defined for this S4 class, returning NULL
>> vcov(fit2)
> lymax lxhalf
> lymax 0.02857612 -0.04870231
> lxhalf -0.04870231 0.11457338
>> coef(fit2)
> lymax lxhalf
> 3.218870 1.117006
>
>
> And confint.default does indeed use the generic extractors vcov() and
> coef().
> Q: is this to be expected? and why? (I kind of suspect that this has in
> fact been discussed at some point and that I just wasn't paying
> attention...)
Yes. stats4 contains an object called vcov. confint.default is in the
stats namespace and correctly uses stats::vcov not stats4::vcov, which is
what you were looking for.
It's discussed most weeks, and at R-core in Vienna in 2006 and before
that. It is 'issue' 11 in http://developer.r-project.org/BDR_S4issues.txt
Brian
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel
mailing list