From ripley at stats.ox.ac.uk  Tue Feb 12 19:43:05 2008
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue, 12 Feb 2008 18:43:05 +0000 (GMT)
Subject: [Rd] Namespace/method oddity
In-Reply-To: <47B1E04D.1050104@biostat.ku.dk>
References: <47B1E04D.1050104@biostat.ku.dk>
Message-ID: <alpine.LFD.1.00.0802121833130.23632@gannet.stats.ox.ac.uk>

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



[Rd] Namespace/method oddity
Prof Brian Ripley