[R] how to get Residual Standard Error
Uwe Ligges
ligges at statistik.uni-dortmund.de
Sat Dec 14 19:55:03 CET 2002
Zhongming Yang wrote:
>
> Thanks for your answer.
>
> But I really want to know whether I can get "Residual Standard Error",
> directly. If I use summary(), there is an item "Residual Standard
> Error". So I think we might can access this information directly.
>
> Thanks again,
Well, you can get it with summary(x)$sigma, if class(x) == "lm"
(Attention: it might be completely different for other classes!).
summary() calculates much more than this value, thus it is much faster
to calculate it *directly*, i.e. in the way Douglas Bates already
pointed out.
Uwe Ligges
> > summary(mod)
> Call:
> loess(formula = y ~ x)
>
> Number of Observations: 10
> Equivalent Number of Parameters: 4.95
> Residual Standard Error: 8.734e-16
> Trace of smoother matrix: 5.47
>
> Control settings:
> normalize: TRUE
> span : 0.75
> degree : 2
> family : gaussian
> surface : interpolate cell = 0.2
>
> >>> Douglas Bates <bates at stat.wisc.edu> 12/13/02 04:15PM >>>
> "Zhongming Yang" <Zhongming.Yang at cchmc.org> writes:
>
> > Hi,
> >
> > I use lm or loess to make smoothing. After smoothing I need
> "Residual
> > Standard Error" in my script. Could you please tell me how can I get
> > this information?
>
> A preferred way would be to use
> sqrt(deviance(fm)/df.residual(fm))
> if fm is your fitted model.
>
> pFor example
>
> > data(Formaldehyde)
> > fm <- lm(optden ~ carb, data = Formaldehyde)
> > summary(fm)
>
> Call:
> lm(formula = optden ~ carb, data = Formaldehyde)
>
> Residuals:
> 1 2 3 4 5 6
> -0.006714 0.001029 0.002771 0.007143 0.007514 -0.011743
>
> Coefficients:
> Estimate Std. Error t value Pr(>|t|)
> (Intercept) 0.005086 0.007834 0.649 0.552
> carb 0.876286 0.013535 64.744 3.41e-07 ***
> ---
> Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
>
> Residual standard error: 0.008649 on 4 degrees of freedom
> Multiple R-Squared: 0.999, Adjusted R-squared: 0.9988
> F-statistic: 4192 on 1 and 4 DF, p-value: 3.409e-07
>
> > sqrt(deviance(fm)/df.residual(fm))
> [1] 0.0086487
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
More information about the R-help
mailing list