Greene. Econometric Analysis, 8ed.

CHAPTER 5. Hypothesis Tests and Model Selection

Example 5.1

library(AER)
library(dynlm)
library(dplyr)

Art Appreciation

art <- read.csv("data/TableF4-1.csv", fileEncoding="UTF-8-BOM", header=TRUE)
art$lnP <- log(art$PRICE)
art$Aratio <- art$WIDTH / art$HEIGHT art$lnArea <- log(art$HEIGHT * art$WIDTH)
summary(OLS1<-lm(lnP ~ lnArea + Aratio, data=art))
##
## Call:
## lm(formula = lnP ~ lnArea + Aratio, data = art)
##
## Residuals:
##     Min      1Q  Median      3Q     Max
## -4.4967 -0.7201 -0.0845  0.7548  3.0073
##
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept) -8.34236    0.67820  -12.30   <2e-16 ***
## lnArea       1.31638    0.09205   14.30   <2e-16 ***
## Aratio      -0.09623    0.15784   -0.61    0.542
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.104 on 427 degrees of freedom
## Multiple R-squared:  0.3342, Adjusted R-squared:  0.3311
## F-statistic: 107.2 on 2 and 427 DF,  p-value: < 2.2e-16
coeftest(OLS1, vcovHC(OLS1, type="HC1"))
##
## t test of coefficients:
##
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept) -8.342361   0.735988 -11.335   <2e-16 ***
## lnArea       1.316384   0.106352  12.378   <2e-16 ***
## Aratio      -0.096233   0.167646  -0.574   0.5663
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Example 5.2

Earnings Equation

earning <- read.csv("data/TableF5-1.csv", fileEncoding="UTF-8-BOM", header=TRUE)

earning$KIDS <- with(earning, factor((KL6 + K618) > 0, levels = c(FALSE, TRUE), labels = c("no", "yes"))) earning$NWINC <- with(earning, (FAMINC - WHRS * WW)/1000)

summary(OLS2 <- lm(log(WHRS * WW) ~ WA + I(WA^2) + WE + KIDS,
data = earning, subset = LFP == 1))
##
## Call:
## lm(formula = log(WHRS * WW) ~ WA + I(WA^2) + WE + KIDS, data = earning,
##     subset = LFP == 1)
##
## Residuals:
##     Min      1Q  Median      3Q     Max
## -4.5305 -0.5266  0.3003  0.8474  1.7568
##
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)
## (Intercept)  3.2400965  1.7674296   1.833  0.06747 .
## WA           0.2005573  0.0838603   2.392  0.01721 *
## I(WA^2)     -0.0023147  0.0009869  -2.345  0.01947 *
## WE           0.0674727  0.0252486   2.672  0.00782 **
## KIDSyes     -0.3511952  0.1475326  -2.380  0.01773 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.19 on 423 degrees of freedom
## Multiple R-squared:  0.041,  Adjusted R-squared:  0.03193
## F-statistic: 4.521 on 4 and 423 DF,  p-value: 0.001382
vcov(OLS2)
##             (Intercept)            WA       I(WA^2)            WE       KIDSyes
## (Intercept)  3.12380756 -1.440901e-01  1.661740e-03 -9.260920e-03  2.674867e-02
## WA          -0.14409007  7.032544e-03 -8.232369e-05  5.085495e-05 -2.641203e-03
## I(WA^2)      0.00166174 -8.232369e-05  9.739279e-07 -4.976114e-07  3.841018e-05
## WE          -0.00926092  5.085495e-05 -4.976114e-07  6.374903e-04 -5.461931e-05
## KIDSyes      0.02674867 -2.641203e-03  3.841018e-05 -5.461931e-05  2.176587e-02

Example 5.3

Restricted Investment Equation

invest <- read.csv("data/TableF5-2.csv", fileEncoding="UTF-8-BOM", header=TRUE)

OLS3a<-dynlm(log(REALINVS) ~ TBILRATE + INFL + log(REALGDP) + trend(invest), data=invest)
summary(OLS3 <- update(OLS3a, start = 2))
##
## Time series regression with "numeric" data:
## Start = 1, End = 203
##
## Call:
## dynlm(formula = log(REALINVS) ~ TBILRATE + INFL + log(REALGDP) +
##     trend(invest), data = invest, start = 2)
##
## Residuals:
##      Min       1Q   Median       3Q      Max
## -0.22313 -0.05540 -0.00312  0.04246  0.31989
##
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)
## (Intercept)   -9.128432   1.364977  -6.688 2.26e-10 ***
## TBILRATE      -0.008598   0.003195  -2.691  0.00774 **
## INFL           0.003306   0.002337   1.415  0.15872
## log(REALGDP)   1.930156   0.183272  10.532  < 2e-16 ***
## trend(invest) -0.005659   0.001488  -3.803  0.00019 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.08618 on 198 degrees of freedom
## Multiple R-squared:  0.9798, Adjusted R-squared:  0.9793
## F-statistic:  2395 on 4 and 198 DF,  p-value: < 2.2e-16
OLS4a<-dynlm(log(REALINVS) ~ I(TBILRATE - INFL) + log(REALGDP) + trend(invest), data=invest)
summary(OLS4 <- update(OLS4a, start = 2))
##
## Time series regression with "numeric" data:
## Start = 1, End = 203
##
## Call:
## dynlm(formula = log(REALINVS) ~ I(TBILRATE - INFL) + log(REALGDP) +
##     trend(invest), data = invest, start = 2)
##
## Residuals:
##       Min        1Q    Median        3Q       Max
## -0.227897 -0.054542 -0.002435  0.039993  0.313928
##
## Coefficients:
##                     Estimate Std. Error t value Pr(>|t|)
## (Intercept)        -7.902755   1.199306  -6.589 3.87e-10 ***
## I(TBILRATE - INFL) -0.004427   0.002270  -1.950  0.05260 .
## log(REALGDP)        1.764062   0.160561  10.987  < 2e-16 ***
## trend(invest)      -0.004403   0.001331  -3.308  0.00111 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0867 on 199 degrees of freedom
## Multiple R-squared:  0.9794, Adjusted R-squared:  0.9791
## F-statistic:  3154 on 3 and 199 DF,  p-value: < 2.2e-16
deviance(OLS3)
## [1] 1.470565
deviance(OLS4)
## [1] 1.495811

Example 5.4F

Test for the Earnings Equation

summary(OLS2)$fstatistic ## value numdf dendf ## 4.52057 4.00000 423.00000 Example 5.5 Production Functions productionf <- read.csv("data/TableF5-3.csv", fileEncoding="UTF-8-BOM", header=TRUE) summary(OLS5 <- lm(log(VALUEADD) ~ log(LABOR) + log(CAPITAL) + I(0.5*log(LABOR)^2) + I(0.5*log(CAPITAL)^2) + log(LABOR):log(CAPITAL), data = productionf)) ## ## Call: ## lm(formula = log(VALUEADD) ~ log(LABOR) + log(CAPITAL) + I(0.5 * ## log(LABOR)^2) + I(0.5 * log(CAPITAL)^2) + log(LABOR):log(CAPITAL), ## data = productionf) ## ## Residuals: ## Min 1Q Median 3Q Max ## -0.33990 -0.10106 -0.01238 0.04605 0.39281 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 0.94420 2.91075 0.324 0.7489 ## log(LABOR) 3.61364 1.54807 2.334 0.0296 * ## log(CAPITAL) -1.89311 1.01626 -1.863 0.0765 . ## I(0.5 * log(LABOR)^2) -0.96405 0.70738 -1.363 0.1874 ## I(0.5 * log(CAPITAL)^2) 0.08529 0.29261 0.291 0.7735 ## log(LABOR):log(CAPITAL) 0.31239 0.43893 0.712 0.4845 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 0.1799 on 21 degrees of freedom ## Multiple R-squared: 0.9549, Adjusted R-squared: 0.9441 ## F-statistic: 88.85 on 5 and 21 DF, p-value: 2.121e-13 vcov(OLS5) ## (Intercept) log(LABOR) log(CAPITAL) ## (Intercept) 8.47248687 -2.38790338 -0.33129294 ## log(LABOR) -2.38790338 2.39652901 -1.23101576 ## log(CAPITAL) -0.33129294 -1.23101576 1.03278652 ## I(0.5 * log(LABOR)^2) -0.08760011 -0.66580411 0.52305244 ## I(0.5 * log(CAPITAL)^2) -0.23317345 0.03476689 0.02636926 ## log(LABOR):log(CAPITAL) 0.36354446 0.18311307 -0.22554189 ## I(0.5 * log(LABOR)^2) I(0.5 * log(CAPITAL)^2) ## (Intercept) -0.08760011 -0.23317345 ## log(LABOR) -0.66580411 0.03476689 ## log(CAPITAL) 0.52305244 0.02636926 ## I(0.5 * log(LABOR)^2) 0.50039330 0.14674300 ## I(0.5 * log(CAPITAL)^2) 0.14674300 0.08562001 ## log(LABOR):log(CAPITAL) -0.28803386 -0.11604045 ## log(LABOR):log(CAPITAL) ## (Intercept) 0.3635445 ## log(LABOR) 0.1831131 ## log(CAPITAL) -0.2255419 ## I(0.5 * log(LABOR)^2) -0.2880339 ## I(0.5 * log(CAPITAL)^2) -0.1160405 ## log(LABOR):log(CAPITAL) 0.1926571 Example 5.6 A Long-Run Marginal Propensity to Consume invest <- invest%>% mutate(lagC = lag(log(REALCONS), 1), lagY = lag(log(REALDPI), 1)) summary(OLS6<-lm(log(REALCONS) ~ log(REALDPI) + lagC, data=invest)) ## ## Call: ## lm(formula = log(REALCONS) ~ log(REALDPI) + lagC, data = invest) ## ## Residuals: ## Min 1Q Median 3Q Max ## -0.035243 -0.004606 0.000496 0.005147 0.041754 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 0.003142 0.010553 0.298 0.76624 ## log(REALDPI) 0.074958 0.028727 2.609 0.00976 ** ## lagC 0.924625 0.028594 32.337 < 2e-16 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 0.008742 on 200 degrees of freedom ## (1 observation deleted due to missingness) ## Multiple R-squared: 0.9997, Adjusted R-squared: 0.9997 ## F-statistic: 3.476e+05 on 2 and 200 DF, p-value: < 2.2e-16 Example 5.7 J Test for a Consumption Function summary(OLS7<-lm(log(REALCONS) ~ log(REALDPI) + lagY, data=invest)) ## ## Call: ## lm(formula = log(REALCONS) ~ log(REALDPI) + lagY, data = invest) ## ## Residuals: ## Min 1Q Median 3Q Max ## -0.049108 -0.013531 -0.000803 0.011245 0.067266 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) -0.13247 0.02431 -5.448 1.48e-07 *** ## log(REALDPI) 0.86831 0.17601 4.933 1.70e-06 *** ## lagY 0.13454 0.17571 0.766 0.445 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 0.02179 on 200 degrees of freedom ## (1 observation deleted due to missingness) ## Multiple R-squared: 0.9982, Adjusted R-squared: 0.9982 ## F-statistic: 5.589e+04 on 2 and 200 DF, p-value: < 2.2e-16 jtest(OLS7, OLS6) ## J test ## ## Model 1: log(REALCONS) ~ log(REALDPI) + lagY ## Model 2: log(REALCONS) ~ log(REALDPI) + lagC ## Estimate Std. Error t value Pr(>|t|) ## M1 + fitted(M2) 1.0432 0.02907 35.8828 < 2.2e-16 *** ## M2 + fitted(M1) -3.1307 0.49267 -6.3546 1.396e-09 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Example 5.8 Size of a RESET Test set.seed(123) bstar = NULL n = length(art$lnP); B = 5000
for(draw in 1:B)
{
Dstar = art[sample(1:n, size=n, replace=T),]
model = lm(lnP ~ lnArea + Aratio, data=Dstar)
bstar = rbind( bstar, coef(model) )
}
LS5000 <- cbind(LS5000_b=colMeans(bstar), LS5000_se=sqrt(diag(var(bstar))))
LS5000
##                LS5000_b LS5000_se
## (Intercept) -8.37947283 0.7495613
## lnArea       1.32203910 0.1080326
## Aratio      -0.09665372 0.1702822