[R] meaning of sigma from LM, is it the same as RMSE

Mark Difford mark_difford at yahoo.co.uk
Thu Apr 5 09:45:23 CEST 2012


On Apr 05, 2012; 1:47am John Sorkin wrote:

> Is the sigma from a lm...the RMSE (root mean square error)

John,

RMSE is usually calculated using the number of observations/cases, whereas
summary.lm()$sigma is calculated using the residual degrees of freedom. See
below:

## Helps to study the output of anova()
set.seed(231)
x <- rnorm(20, 2, .5)
y <- rnorm(20, 2, .7)
T.lm <- lm(y ~ x)
> summary(T.lm)$sigma
[1] 0.7403162
> anova(T.lm)
Analysis of Variance Table

Response: y
          Df Sum Sq Mean Sq F value Pr(>F)
x          1 0.0036 0.00360  0.0066 0.9363
Residuals 18 9.8652 0.54807

> sum(resid(T.lm)^2)
[1] 9.865225
> sqrt(sum(resid(T.lm)^2)/18)
[1] 0.7403162
> sqrt(sum(resid(T.lm)^2)/20)  ## RMSE (y = 20)
[1] 0.7023256
## OR
> sqrt(mean((y-fitted(T.lm))^2))
[1] 0.7023256

Regards, Mark.

-----
Mark Difford (Ph.D.)
Research Associate
Botany Department
Nelson Mandela Metropolitan University
Port Elizabeth, South Africa
--
View this message in context: http://r.789695.n4.nabble.com/meaning-of-sigma-from-LM-is-it-the-same-as-RMSE-tp4533515p4534165.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list