6.7 Multiple regression in software
Software 6.7.1 (A multiple regression). The life-cycle model of savings with all four regressors:
> fit <- lm(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings) > summary(fit) Call: lm(formula = sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings) Residuals: Min 1Q Median 3Q Max -8.2422 -2.6857 -0.2488 2.4280 9.7509 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 28.5660865 7.3545161 3.884 0.000334 *** pop15 -0.4611931 0.1446422 -3.189 0.002603 ** pop75 -1.6914977 1.0835989 -1.561 0.125530 dpi -0.0003369 0.0009311 -0.362 0.719173 ddpi 0.4096949 0.1961971 2.088 0.042471 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.803 on 45 degrees of freedom Multiple R-squared: 0.3385, Adjusted R-squared: 0.2797 F-statistic: 5.756 on 4 and 45 DF, p-value: 0.0007904
Reading the output. Each coefficient is a partial effect in the sense of Theorem 6.4.1. A country with a young-dependant share one point higher, and the same old-age share, income and income growth, saves \(0.46\) points less: twice the effect found by the simple regression of Software 2.6.1, which confounded pop15 with the variables correlated with it. The sign of pop75 has reversed. Its simple correlation with savings is \(+0.317\), but holding pop15 fixed its coefficient is \(-1.69\), the negative sign the life-cycle theory predicts for dissaving by the elderly, though it is not significant. Faster income growth raises savings. The residual degrees of freedom are \(n - k = 50 - 5 = 45\), and \(\bar R^2 = 1 - (1 - 0.3385)(49/45) = 0.2797\). The \(F\) statistic tests that all four slopes are zero; it is derived in the next section.
Stata: regress sr pop15 pop75 dpi ddpi. EViews: ls sr c pop15 pop75 dpi ddpi.
Software 6.7.2 (Frisch–Waugh–Lovell by hand). Partial pop75, dpi and ddpi out of both sr and pop15, then regress residual on residual:
> ry <- resid(lm(sr ~ pop75 + dpi + ddpi, data = LifeCycleSavings)) > rx <- resid(lm(pop15 ~ pop75 + dpi + ddpi, data = LifeCycleSavings)) > coef(lm(ry ~ rx - 1)) rx -0.4611931 > cor(ry, rx) [1] -0.4292889
Reading the output. The coefficient \(-0.4611931\) is identical, to every digit, to the pop15 coefficient in the full regression. The - 1 omits the intercept, which is unnecessary because both residual series have mean zero. The correlation of the two residual series, \(-0.429\), is the partial correlation of savings with pop15 given the other three regressors. It is linked to the \(t\) ratio by \(r^2 = t^2/(t^2 + n - k) = 3.189^2/(3.189^2 + 45) = 0.184 = 0.429^2\) (Problem 6.8.3).
Stata: regress sr pop75 dpi ddpi, predict ry, resid, and similarly for rx; pcorr sr pop15 pop75 dpi ddpi gives partial correlations directly. EViews: ls sr c pop75 dpi ddpi, then series ry = resid.
Software 6.7.3 (\(R^2\) and a useless regressor). Add a column of random numbers to the savings regression:
> set.seed(1); LCS <- LifeCycleSavings; LCS$noise <- rnorm(50) > f2 <- lm(sr ~ pop15 + pop75 + dpi + ddpi + noise, data = LCS) > c(R2 = summary(fit)$r.squared, adjR2 = summary(fit)$adj.r.squared) R2 adjR2 0.3384564 0.2796525 > c(R2 = summary(f2)$r.squared, adjR2 = summary(f2)$adj.r.squared) R2 adjR2 0.3439879 0.2694411 > summary(f2)$coef["noise", ] Estimate Std. Error t value Pr(>|t|) -0.4133420 0.6786050 -0.6091055 0.5455868
Reading the output. \(R^2\) rises, from \(0.3385\) to \(0.3440\), although the new variable is pure noise, as Theorem 6.3.2 guarantees it must. The adjusted \(R^2\) falls, from \(0.2797\) to \(0.2694\), consistent with the noise variable’s \(|t| = 0.61 < 1\). Choosing a model by maximising \(R^2\) would always choose the biggest model.
Stata: generate noise = rnormal() after set seed 1 (the numbers will differ from R’s). EViews: series noise = nrnd.
Questions on this section
Stuck on something here? Ask below and it stays attached to this topic.