Re: R-beta: standard-errors-glm --- using str(.) ..

Martin Maechler (maechler@stat.math.ethz.ch)
Mon, 6 Apr 1998 10:40:12 +0200


Date: Mon, 6 Apr 1998 10:40:12 +0200
Message-Id: <199804060840.KAA00540@sophie.ethz.ch>
From: Martin Maechler <maechler@stat.math.ethz.ch>
To: helgito@hag.hi.is, r-help@stat.math.ethz.ch
Subject: Re: R-beta: standard-errors-glm --- using  str(.) ..

>>>>> "Bill" == Bill Venables <wvenable@attunga.stats.adelaide.edu.au> writes:

    Bill> Helgi Tomasson writes:
    >> out <- glm(....)  summary(out)

    >> I want to get the standard errors from the output.

    >> SE <- summary(out)$coef[, 2]

    >> How do I get the covariance matrix of the estimates?

    >> summary(out)$covmat

    Bill> If you want several things from the summary it is less
    Bill> computation to create the object once and then extract them.

    >> out <- glm(...)  sout <- summary(out) sout
    Bill>  .  .  .
 
    >> SE <- sout$coef[, 2] Vm <- sout$covmat

    Bill> Also

    >> names(sout)

    Bill> gives a good idea what else is buried in the summary object.
    Bill> Remember that when you print an object you don't necessarily see
    Bill> everything that is there.  (This is a feature, not a bug!)

And to put in my favorite:

In R, (and in S if you get it from Statlib),
you can also use

	str(sout)
	---------  "STRucture of 'sout'"
to show a little more than just the names, but still quite compactly,
especially when called as

	str(sout, give.attr = FALSE, max=1)

E.g. for the Annette Dobson's example from  "?glm" 
(and current "unstable" version 0.62 of R):

> sout <-summary(glm.D93)
> str(sout, give.attr=F, max=1)
List of 17
 $ call          : language glm(formula = counts ~ outcome + treatment, family = poisson())
 $ terms         :Class 'terms' length 3 counts ~ outcome + treatment
 $ family        :List of 11
 $ deviance      : num 5.13
 $ aic           : num 56.8
 $ contrasts     : Named chr [1:2] contr.treatment contr.poly
 $ df.residual   : num 4
 $ null.deviance : num 10.6
 $ df.null       : num 8
 $ iter          : int 2
 $ deviance.resid: num [1:9] -0.671  0.963 -0.170 -0.220 -0.956 ...
 $ aic           : num 56.8
 $ coefficients  : num [1:5, 1:4]  3.04e+00 -4.54e-01 -2.93e-01  1.92e-08  8.38e-09 ...
 $ dispersion    : num 1
 $ df            : num [1:2] 5 4
 $ cov.unscaled  : num [1:5, 1:5]  0.0292 -0.0159 -0.0159 -0.0200 -0.0200 ...
 $ cov.scaled    : num [1:5, 1:5]  0.0292 -0.0159 -0.0159 -0.0200 -0.0200 ...
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._