Win2k, R1.6.2. I've been using Splus 6.1 and wanted to try the same regression analysis in R. Using "names( blah.lm )" in R yields [1] "coefficients" "residuals" "effects" "rank" [5] "fitted.values" "assign" "qr" "df.residual" [9] "xlevels" "call" "terms" "model" In Splus, the same command yields [1] "coefficients" "residuals" "fitted.values" "effects" [5] "R" "rank" "assign" "df.residual" [9] "contrasts" "terms" "call" and blah.lm$R gives the variance-covariance matrix of the model parameters. How do get the variance-covariance matrix out of R? Apologies for such a simple question. Much thanks in advance, david paul
Dear David, vcov(blah.lm) will do the trick. John At 06:51 PM 4/23/2003 -0400, Paul, David A wrote:>Win2k, R1.6.2. > >I've been using Splus 6.1 and wanted to try the same >regression analysis in R. Using "names( blah.lm )" >in R yields > > [1] "coefficients" "residuals" "effects" "rank" > [5] "fitted.values" "assign" "qr" "df.residual" > [9] "xlevels" "call" "terms" "model" > >In Splus, the same command yields > > [1] "coefficients" "residuals" "fitted.values" "effects" > [5] "R" "rank" "assign" "df.residual" > [9] "contrasts" "terms" "call" > >and blah.lm$R gives the variance-covariance matrix of the >model parameters. How do get the variance-covariance matrix out >of R? Apologies for such a simple question. > >Much thanks in advance, > david paul > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://www.stat.math.ethz.ch/mailman/listinfo/r-help----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox
>>>>> "DavidP" == Paul, David A <paulda at BATTELLE.ORG> >>>>> on Wed, 23 Apr 2003 18:51:39 -0400 writes:DavidP> Win2k, R1.6.2. DavidP> I've been using Splus 6.1 and wanted to try the same DavidP> regression analysis in R. Using "names( blah.lm )" DavidP> in R yields DavidP> [1] "coefficients" "residuals" "effects" "rank" DavidP> [5] "fitted.values" "assign" "qr" "df.residual" DavidP> [9] "xlevels" "call" "terms" "model" DavidP> In Splus, the same command yields DavidP> [1] "coefficients" "residuals" "fitted.values" "effects" DavidP> [5] "R" "rank" "assign" "df.residual" DavidP> [9] "contrasts" "terms" "call" DavidP> and blah.lm$R gives the variance-covariance matrix of the DavidP> model parameters. How do get the variance-covariance matrix out DavidP> of R? Apologies for such a simple question. The most recommended way is to use the generic function vcov() which has methods for many classes, included "lm". A bit more low level, but still reliable approach is to do what vcov.lm does: vcov.lm <- function (object, ...) { so <- summary.lm(object, corr = FALSE) so$sigma^2 * so$cov.unscaled } A much more low level (non-recommended) way would be to look at <your lm object> $ qr etc and replicate what summary.lm() is doing for its $sigma and $cov.unscaled computations. DavidP> Much thanks in advance, you're welcome! Martin Maechler ETH Zurich