[R] model constant relations
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Nov 10 14:25:56 CET 2003
On Mon, 10 Nov 2003, Spencer Graves wrote:
> Have you looked at the correlation of the parameter estimates?
>
> In S-Plus, this is automatically produced by summary(lm(...)).
> There is probably a simple, elegant way to get this in R, but I don't
> know it. Therefore, I produced it as follows:
summary(fit, cor=TRUE) : the default is different between R and S
(intentionally).
See also ?vcov.
> > DF <- data.frame(x=1:12, y=rep(1:6, each=2))
> > fit <- lm(y~x, DF)
> > sumfit <- summary(fit)
> > cov.fit <- sumfit$cov.unscaled
> > seb <- sqrt(diag(cov.fit))
> > cov.fit / outer(seb, seb)
> (Intercept) x
> (Intercept) 1.000000 -0.883176
> x -0.883176 1.000000
>
> I developed this by looking at attributes(fit), then attributes(sumfit),
> etc.
--
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-help
mailing list