import pandas as pd
from statsmodels.formula.api import ols as OLS
wage2 = pd.read_csv('csv/wooldridge/wage2.csv')
fm = 'lwage~educ+exper+tenure+married+south+urban+black'
print(OLS(fm, data=wage2).fit().summary())
OLS Regression Results ============================================================================== Dep. Variable: lwage R-squared: 0.253 Model: OLS Adj. R-squared: 0.247 Method: Least Squares F-statistic: 44.75 Date: Fri, 16 Dec 2022 Prob (F-statistic): 1.16e-54 Time: 15:43:58 Log-Likelihood: -381.55 No. Observations: 935 AIC: 779.1 Df Residuals: 927 BIC: 817.8 Df Model: 7 Covariance Type: nonrobust ============================================================================== coef std err t P>|t| [0.025 0.975] ------------------------------------------------------------------------------ Intercept 5.3955 0.113 47.653 0.000 5.173 5.618 educ 0.0654 0.006 10.468 0.000 0.053 0.078 exper 0.0140 0.003 4.409 0.000 0.008 0.020 tenure 0.0117 0.002 4.789 0.000 0.007 0.017 married 0.1994 0.039 5.107 0.000 0.123 0.276 south -0.0909 0.026 -3.463 0.001 -0.142 -0.039 urban 0.1839 0.027 6.822 0.000 0.131 0.237 black -0.1883 0.038 -5.000 0.000 -0.262 -0.114 ============================================================================== Omnibus: 38.227 Durbin-Watson: 1.823 Prob(Omnibus): 0.000 Jarque-Bera (JB): 83.390 Skew: -0.224 Prob(JB): 7.80e-19 Kurtosis: 4.393 Cond. No. 187. ============================================================================== Notes: [1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
print(OLS(fm+'+IQ', data=wage2).fit().summary())
OLS Regression Results ============================================================================== Dep. Variable: lwage R-squared: 0.263 Model: OLS Adj. R-squared: 0.256 Method: Least Squares F-statistic: 41.27 Date: Fri, 16 Dec 2022 Prob (F-statistic): 1.52e-56 Time: 15:44:23 Log-Likelihood: -375.09 No. Observations: 935 AIC: 768.2 Df Residuals: 926 BIC: 811.7 Df Model: 8 Covariance Type: nonrobust ============================================================================== coef std err t P>|t| [0.025 0.975] ------------------------------------------------------------------------------ Intercept 5.1764 0.128 40.441 0.000 4.925 5.428 educ 0.0544 0.007 7.853 0.000 0.041 0.068 exper 0.0141 0.003 4.469 0.000 0.008 0.020 tenure 0.0114 0.002 4.671 0.000 0.007 0.016 married 0.1998 0.039 5.148 0.000 0.124 0.276 south -0.0802 0.026 -3.054 0.002 -0.132 -0.029 urban 0.1819 0.027 6.791 0.000 0.129 0.235 black -0.1431 0.039 -3.624 0.000 -0.221 -0.066 IQ 0.0036 0.001 3.589 0.000 0.002 0.006 ============================================================================== Omnibus: 43.456 Durbin-Watson: 1.820 Prob(Omnibus): 0.000 Jarque-Bera (JB): 99.739 Skew: -0.248 Prob(JB): 2.20e-22 Kurtosis: 4.521 Cond. No. 1.13e+03 ============================================================================== Notes: [1] Standard Errors assume that the covariance matrix of the errors is correctly specified. [2] The condition number is large, 1.13e+03. This might indicate that there are strong multicollinearity or other numerical problems.