If we type lm.fit
, some basic information about the model is output.
> lm.fit
Call:
lm(formula = medv ~ lstat)
Coefficients:
(Intercept ) lstat
34.55 -0.95
For more detailed information, we use summary(lm.fit)
.
This gives us p-values and standard errors for the coefficients, as well as the R² statistic and F-statistic for the model.
> summary (lm.fit)
Call:
lm(formula = medv ~ lstat)
Residuals :
Min 1Q Median 3Q Max
-15.17 -3.99 -1.32 2.03 24.50
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 34.5538 0.5626 61.4 <2e-16 ***
lstat -0.9500 0.0387 -24.5 <2e-16 ***
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Residual standard error: 6.22 on 504 degrees of freedom
Multiple R-squared: 0.544, Adjusted R-squared: 0.543
F-statistic : 602 on 1 and 504 DF, p-value: <2e-16
There is much to dissect in this summary. Firstly, the call that was used to create the regression model.
Call:
lm(formula = medv ~ lstat)
Some information about the residuals.
Residuals :
Min 1Q Median 3Q Max
-15.17 -3.99 -1.32 2.03 24.50
This is our regression equation:
\[{medv} = \beta_{0} + \beta_{1} {lstat}\]Below we can find the value for \(\beta_{0}\) and \(\beta_{1}\) being 34.5538 and -0.9500. This gives us:
\[{medv} = 34.5538 - 0.9500 {lstat}\]Additionally, we are also given the standard error, t-values and p-values of every coefficient in our model. We can conclude that both the intercept and lstat are significant (p < 0.05).
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept ) 34.5538 0.5626 61.4 <2e-16 ***
lstat -0.9500 0.0387 -24.5 <2e-16 ***
To make it simpler for us, R also uses significance codes. One *
tells us that the p-value is smaller than 0.05.
**
and ***
means p-values smaller than 0.01 and 0.001 respectively. In our case both of our p-values are close to 0,
with both being smaller than \(2*10^{-16}\).
The \(R^2\) of our model is 0.544 and \(\bar{R}^2\) is 0.543
Multiple R-squared: 0.544, Adjusted R-squared: 0.543
Lastly, to see if our model in general has any explanatory power over our dependent variable, we can use the F-statistic.
F-statistic : 602 on 1 and 504 DF, p-value: <2e-16
Here we can reject H0 that the fit of the full model equals the fit of the null model (p < 0.05).