Re: [R] rms: getting adjusted R^2 from ols object

From: Martyn Byng <Martyn.Byng_at_nag.co.uk>
Date: Wed, 09 Mar 2011 09:25:08 +0000

Hi,

If you look in the print.ols function you can see that the adjusted R^2 is not stored in the ols object but calculated on the fly, the relevant code snippet from that function looks to be:

    x <- ols1

    stats <- x$stats
    resid <- x$residuals
    n <- length(resid)
    ndf <- stats["d.f."]
    df <- c(ndf, n - ndf - 1, ndf)
    r2 <- stats["R2"]
    rdf <- df[2]
    rsqa <- 1 - (1 - r2) * (n - 1)/rdf

Martyn

-----Original Message-----
From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] On Behalf Of Mark Seeto
Sent: 09 March 2011 09:10
To: r-help_at_r-project.org
Subject: [R] rms: getting adjusted R^2 from ols object

How can I extract the adjusted R^2 value from an ols object (using rms package)?

library(rms)
x <- rnorm(10)
y <- x + rnorm(10)
ols1 <- ols(y ~ x)

Typing "ols1" displays adjusted R^2 among other things, but how can I assign it to a variable? I tried str(ols1) but couldn't see where to go from there.

Thanks,
Mark Seeto



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 09 Mar 2011 - 09:27:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 09 Mar 2011 - 12:50:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive