Section 8.13 Key Functions & Commands
The following functions and commands are introduced or reinforced in this chapter to support linear regression modeling, diagnostics, and model selection.
-
lm()(stats)-
Fits linear and multiple linear regression models using a formula interface.
-
-
summary()(base R)-
Summarizes regression model results, including coefficients, RΒ², F-statistic, and p-values.
-
-
cor.test()(stats)-
Computes and tests correlations to assess whether predictors are suitable for regression.
-
-
predict()(stats)-
Generates predicted values from a fitted regression model.
-
-
residuals()(stats)-
Extracts residuals (actual β predicted values) from a regression model.
-
-
tidy()(broom)-
Converts regression coefficients into a clean, tidy data frame.
-
-
glance()(broom)-
Extracts model-level statistics (e.g., RΒ², adjusted RΒ², AIC) into a single-row summary.
-
-
bptest()(lmtest)-
Performs the BreuschβPagan test to assess heteroscedasticity of residuals.
-
-
AIC()(stats)-
Compares regression models using Akaike Information Criterion to balance fit and complexity.
-
-
step()(stats)-
Performs stepwise model selection to identify a parsimonious regression model.
-
