Testing for significance and validating models
Up to this point in the chapter, we have discussed the concepts of the OLS approach to linear regression modeling; the coefficients in a linear model; the coefficients of correlation and determination; and the assumptions required for modeling with linear regression. We will now begin our discussion on testing for significance and model validation.
Testing for significance
To test for significance, let us load statsmodels
macrodata data set so we can build a model that tests the relationship between real gross private domestic investment, realinv
, and real private disposable income, realdpi
:
import numpy as np import pandas as pd import seaborn as sns import statsmodels.api as sm import matplotlib.pyplot as plt from statsmodels.nonparametric.smoothers_lowess import lowess df = sm.datasets.macrodata.load().data
Least squares regression requires a constant coefficient in order to derive the intercept. In the least squares equation...