[R] Seeing the definition of a function

Liaw, Andy andy_liaw at merck.com
Tue May 4 15:36:25 CEST 2004


You _are_ looking at the definition of confint(), which is a generic.  What
you're probably interested in are the methods, which you can find by:

> methods("confint")
[1] confint.lm*

    Non-visible functions are asterisked

> getAnywhere("confint.lm")
A single object matching 'confint.lm' was found
It was found in the following places
  registered S3 method for confint from namespace stats
  namespace:stats
with value

function (object, parm, level = 0.95, ...) 
{
    cf <- coef(object)
    pnames <- names(cf)
    if (missing(parm)) 
        parm <- seq(along = pnames)
    else if (is.character(parm)) 
        parm <- match(parm, pnames, nomatch = 0)
    a <- (1 - level)/2
    a <- c(a, 1 - a)
    pct <- paste(round(100 * a, 1), "%")
    ci <- array(NA, dim = c(length(parm), 2), dimnames = list(pnames[parm], 
        pct))
    ses <- sqrt(diag(vcov(object)))[parm]
    fac <- qt(a, object$df.residual)
    ci[] <- cf[parm] + ses %o% fac
    ci
}
<environment: namespace:stats>

You'll probably want to read a bit about how S3 methods work (e.g., in the
White Book).

HTH,
Andy


> From: Søren Højsgaard
> 
> Dear all,
> I was trying to see how the function 'confint' is defined. Doing
> 
> > confint
> function (object, parm, level = 0.95, ...) 
> UseMethod("confint")
> <environment: namespace:stats>
> 
> does not really enlighten me. How can I get to see the 
> implementation (I guess it should be possible according to 
> the general philosophy of the R project)?
> 
> Thanks in advance
> Søren
> 
> ==============================================================
> =============================== 
> Søren Højsgaard,  PhD, Head of Research Unit    Phone: +45 8999 1703 
> Biometry Research Unit,                         Fax:     +45 
> 8999 1300 
> Danish Institute of Agricultural Sciences       E-mail: 
> sorenh at agrsci.dk 
> Research Centre Foulum, DK-8830 Tjele, Denmark  Homepage : 
http://www.jbs.agrsci.dk/~sorenh/

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html




More information about the R-help mailing list