Hi,
Why are
- number of (usable or included) observations
- sum of squared residuals (SSE)
not standard output for functions
?stats::lm
?stats::arima
?
How do I calculate them?
Amarjit
Hi,
Why are
not standard output for functions
?stats::lm
?stats::arima
?
How do I calculate them?
Amarjit
The help files show exactly what is contained in each object. In both cases, that provides enough information for you to be able to figure out how to calculate these. Even if the help does not provide the required information you can always see what is contained within an object using str().
The generic residuals() functions will return the residuals from most models, and it does in these two cases.
fit <- lm(mpg ~ cyl + hp, data = mtcars)
n_used <- NROW(fit$model)
e <- residuals(fit)
sum(e^2)
fit <- arima(USAccDeaths)
n_used <- fit$nobs
e <- residuals(fit)
sum(e^2)
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.