library("wooldridge")
## Warning: package 'wooldridge' was built under R version 4.2.3
data <- wooldridge::barium
head(data)
## chnimp bchlimp befile6 affile6 afdec6 befile12 affile12 afdec12 chempi
## 1 220.4620 9578.376 0 0 0 0 0 0 100.1
## 2 94.7980 11219.480 0 0 0 0 0 0 100.9
## 3 219.3575 9719.900 0 0 0 0 0 0 101.1
## 4 317.4215 12920.950 0 0 0 0 0 0 102.5
## 5 114.6390 9790.446 0 0 0 0 0 0 104.1
## 6 129.5240 11020.470 0 0 0 0 0 0 104.8
## gas rtwex spr sum fall lchnimp lgas lrtwex lchempi t feb mar
## 1 7830000128 86.74 0 0 0 5.395725 22.78123 4.462915 4.606170 1 1 0
## 2 8819999744 85.63 1 0 0 4.551748 22.90029 4.450036 4.614130 2 0 1
## 3 8449999872 85.42 1 0 0 5.390703 22.85743 4.447580 4.616110 3 0 0
## 4 9240000512 87.29 1 0 0 5.760231 22.94681 4.469236 4.629863 4 0 0
## 5 9150000128 86.60 0 1 0 4.741788 22.93702 4.461300 4.645352 5 0 0
## 6 9520000000 84.63 0 1 0 4.863866 22.97666 4.438289 4.652054 6 0 0
## apr may jun jul aug sep oct nov dec percchn
## 1 0 0 0 0 0 0 0 0 0 2.3016636
## 2 0 0 0 0 0 0 0 0 0 0.8449411
## 3 1 0 0 0 0 0 0 0 0 2.2567875
## 4 0 1 0 0 0 0 0 0 0 2.4566422
## 5 0 0 1 0 0 0 0 0 0 1.1709272
## 6 0 0 0 1 0 0 0 0 0 1.1753038
Question i).
model1 <- lm(lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 + afdec6 , data = data)
a <- summary(model1)
a
##
## Call:
## lm(formula = lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 +
## afdec6, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.03356 -0.39080 0.03048 0.40248 1.51719
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -17.80300 21.04537 -0.846 0.3992
## lchempi 3.11719 0.47920 6.505 1.72e-09 ***
## lgas 0.19635 0.90662 0.217 0.8289
## lrtwex 0.98302 0.40015 2.457 0.0154 *
## befile6 0.05957 0.26097 0.228 0.8198
## affile6 -0.03241 0.26430 -0.123 0.9026
## afdec6 -0.56524 0.28584 -1.978 0.0502 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5974 on 124 degrees of freedom
## Multiple R-squared: 0.3049, Adjusted R-squared: 0.2712
## F-statistic: 9.064 on 6 and 124 DF, p-value: 3.255e-08
The coefficient is statistically significant at the 5% level. So, only Irtwex is a significant variable. The P-value of Irtwex is 0.0154, which is lower than 0.05.
Question ii).
library(car)
## Warning: package 'car' was built under R version 4.2.3
## Loading required package: carData
## Warning: package 'carData' was built under R version 4.2.3
hypothesis <- c("lchempi = 0", "lgas = 0", "lrtwex = 0", "befile6 = 0", "affile6 = 0", "afdec6 = 0" )
joint_test <- linearHypothesis(model1, hypothesis)
summary(joint_test)
## Res.Df RSS Df Sum of Sq F
## Min. :124.0 Min. :44.25 Min. :6 Min. :19.41 Min. :9.064
## 1st Qu.:125.5 1st Qu.:49.10 1st Qu.:6 1st Qu.:19.41 1st Qu.:9.064
## Median :127.0 Median :53.95 Median :6 Median :19.41 Median :9.064
## Mean :127.0 Mean :53.95 Mean :6 Mean :19.41 Mean :9.064
## 3rd Qu.:128.5 3rd Qu.:58.80 3rd Qu.:6 3rd Qu.:19.41 3rd Qu.:9.064
## Max. :130.0 Max. :63.65 Max. :6 Max. :19.41 Max. :9.064
## NA's :1 NA's :1 NA's :1
## Pr(>F)
## Min. :0
## 1st Qu.:0
## Median :0
## Mean :0
## 3rd Qu.:0
## Max. :0
## NA's :1
model2 <- lm(lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 + afdec6 + feb, data = data)
a <- summary(model2)
a
##
## Call:
## lm(formula = lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 +
## afdec6 + feb, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.0925 -0.4083 0.0486 0.4098 1.4965
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.44114 26.10573 -0.094 0.9257
## lchempi 3.17909 0.48325 6.579 1.22e-09 ***
## lgas -0.46115 1.12207 -0.411 0.6818
## lrtwex 0.85124 0.42154 2.019 0.0456 *
## befile6 0.05365 0.26105 0.206 0.8375
## affile6 -0.01615 0.26481 -0.061 0.9515
## afdec6 -0.55090 0.28621 -1.925 0.0566 .
## feb -0.23360 0.23487 -0.995 0.3219
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5974 on 123 degrees of freedom
## Multiple R-squared: 0.3104, Adjusted R-squared: 0.2712
## F-statistic: 7.909 on 7 and 123 DF, p-value: 6.655e-08
model3 <- lm(lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 + afdec6 + mar, data = data)
a <- summary(model3)
a
##
## Call:
## lm(formula = lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 +
## afdec6 + mar, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.00269 -0.42926 0.04595 0.41132 1.53769
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -21.28305 21.18542 -1.005 0.3171
## lchempi 3.12401 0.47819 6.533 1.53e-09 ***
## lgas 0.33658 0.91165 0.369 0.7126
## lrtwex 1.03134 0.40117 2.571 0.0113 *
## befile6 0.07263 0.26061 0.279 0.7809
## affile6 -0.05681 0.26445 -0.215 0.8303
## afdec6 -0.59262 0.28606 -2.072 0.0404 *
## mar 0.23715 0.19089 1.242 0.2165
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.596 on 123 degrees of freedom
## Multiple R-squared: 0.3135, Adjusted R-squared: 0.2744
## F-statistic: 8.023 on 7 and 123 DF, p-value: 5.178e-08
model4 <- lm(lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 + afdec6 + apr, data = data)
a <- summary(model4)
a
##
## Call:
## lm(formula = lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 +
## afdec6 + apr, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.08025 -0.40966 0.07476 0.36168 1.49712
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -10.599485 21.343575 -0.497 0.6203
## lchempi 3.139957 0.476042 6.596 1.12e-09 ***
## lgas -0.100653 0.917866 -0.110 0.9129
## lrtwex 0.874347 0.402705 2.171 0.0318 *
## befile6 0.105149 0.260591 0.404 0.6873
## affile6 0.007588 0.263549 0.029 0.9771
## afdec6 -0.519064 0.285192 -1.820 0.0712 .
## apr -0.320090 0.192801 -1.660 0.0994 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5932 on 123 degrees of freedom
## Multiple R-squared: 0.3201, Adjusted R-squared: 0.2814
## F-statistic: 8.273 on 7 and 123 DF, p-value: 2.998e-08
model5 <- lm(lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 + afdec6 + may, data = data)
a <- summary(model5)
a
##
## Call:
## lm(formula = lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 +
## afdec6 + may, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.02561 -0.37818 0.03768 0.40558 1.40003
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -16.50456 21.17616 -0.779 0.4372
## lchempi 3.13182 0.48071 6.515 1.67e-09 ***
## lgas 0.13936 0.91239 0.153 0.8789
## lrtwex 0.96626 0.40177 2.405 0.0177 *
## befile6 0.05183 0.26178 0.198 0.8434
## affile6 -0.02004 0.26548 -0.075 0.9400
## afdec6 -0.55254 0.28705 -1.925 0.0566 .
## may 0.13033 0.19072 0.683 0.4957
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5986 on 123 degrees of freedom
## Multiple R-squared: 0.3075, Adjusted R-squared: 0.2681
## F-statistic: 7.802 on 7 and 123 DF, p-value: 8.436e-08
model6 <- lm(lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 + afdec6 + jun, data = data)
a <- summary(model6)
a
##
## Call:
## lm(formula = lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 +
## afdec6 + jun, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.0413 -0.3769 0.0439 0.4090 1.5031
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -18.98250 21.15475 -0.897 0.3713
## lchempi 3.10448 0.48052 6.461 2.19e-09 ***
## lgas 0.24643 0.91125 0.270 0.7873
## lrtwex 1.00641 0.40234 2.501 0.0137 *
## befile6 0.06628 0.26168 0.253 0.8005
## affile6 -0.04698 0.26564 -0.177 0.8599
## afdec6 -0.58134 0.28733 -2.023 0.0452 *
## jun -0.13426 0.19070 -0.704 0.4828
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5986 on 123 degrees of freedom
## Multiple R-squared: 0.3077, Adjusted R-squared: 0.2683
## F-statistic: 7.808 on 7 and 123 DF, p-value: 8.327e-08
model7 <- lm(lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 + afdec6 + jul, data = data)
a <- summary(model7)
a
##
## Call:
## lm(formula = lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 +
## afdec6 + jul, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.03322 -0.38904 0.03496 0.40244 1.52179
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -16.44296 21.86520 -0.752 0.4535
## lchempi 3.12445 0.48197 6.483 1.97e-09 ***
## lgas 0.13822 0.94145 0.147 0.8835
## lrtwex 0.96781 0.40660 2.380 0.0188 *
## befile6 0.05772 0.26208 0.220 0.8260
## affile6 -0.02776 0.26601 -0.104 0.9171
## afdec6 -0.56031 0.28765 -1.948 0.0537 .
## jul 0.04753 0.19702 0.241 0.8098
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5996 on 123 degrees of freedom
## Multiple R-squared: 0.3052, Adjusted R-squared: 0.2656
## F-statistic: 7.718 on 7 and 123 DF, p-value: 1.016e-07
model8 <- lm(lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 + afdec6 + aug, data = data)
a <- summary(model8)
a
##
## Call:
## lm(formula = lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 +
## afdec6 + aug, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.03442 -0.39070 0.01653 0.41046 1.50470
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -21.59195 21.75833 -0.992 0.3230
## lchempi 3.10478 0.48049 6.462 2.18e-09 ***
## lgas 0.35617 0.93616 0.380 0.7043
## lrtwex 1.02793 0.40597 2.532 0.0126 *
## befile6 0.06497 0.26161 0.248 0.8043
## affile6 -0.04661 0.26559 -0.175 0.8610
## afdec6 -0.58087 0.28726 -2.022 0.0453 *
## aug -0.13862 0.19608 -0.707 0.4809
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5986 on 123 degrees of freedom
## Multiple R-squared: 0.3077, Adjusted R-squared: 0.2683
## F-statistic: 7.809 on 7 and 123 DF, p-value: 8.311e-08
model9 <- lm(lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 + afdec6 + sep, data = data)
a <- summary(model9)
a
##
## Call:
## lm(formula = lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 +
## afdec6 + sep, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.03532 -0.39353 0.02849 0.40243 1.51520
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -17.76454 21.13180 -0.841 0.4022
## lchempi 3.11976 0.48157 6.478 2.01e-09 ***
## lgas 0.19372 0.91049 0.213 0.8319
## lrtwex 0.98550 0.40226 2.450 0.0157 *
## befile6 0.06096 0.26226 0.232 0.8166
## affile6 -0.03518 0.26632 -0.132 0.8951
## afdec6 -0.56851 0.28821 -1.973 0.0508 .
## sep -0.02335 0.19075 -0.122 0.9028
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5997 on 123 degrees of freedom
## Multiple R-squared: 0.3049, Adjusted R-squared: 0.2654
## F-statistic: 7.709 on 7 and 123 DF, p-value: 1.036e-07
model10 <- lm(lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 + afdec6 + oct, data = data)
a <- summary(model10)
a
##
## Call:
## lm(formula = lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 +
## afdec6 + oct, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.01971 -0.38506 0.03717 0.40946 1.53496
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -17.800833 21.059325 -0.845 0.3996
## lchempi 3.106504 0.479662 6.476 2.03e-09 ***
## lgas 0.202730 0.907245 0.223 0.8236
## lrtwex 0.958200 0.401338 2.388 0.0185 *
## befile6 0.080986 0.262191 0.309 0.7579
## affile6 -0.009493 0.265658 -0.036 0.9716
## afdec6 -0.538373 0.287531 -1.872 0.0635 .
## oct 0.173983 0.190314 0.914 0.3624
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5977 on 123 degrees of freedom
## Multiple R-squared: 0.3096, Adjusted R-squared: 0.2703
## F-statistic: 7.878 on 7 and 123 DF, p-value: 7.135e-08
model11 <- lm(lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 + afdec6 + nov, data = data)
a <- summary(model11)
a
##
## Call:
## lm(formula = lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 +
## afdec6 + nov, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.90564 -0.34762 0.04643 0.38502 1.50778
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -18.06552 21.07956 -0.857 0.3931
## lchempi 3.12449 0.48001 6.509 1.72e-09 ***
## lgas 0.20928 0.90812 0.230 0.8181
## lrtwex 0.97072 0.40105 2.420 0.0170 *
## befile6 0.05047 0.26161 0.193 0.8474
## affile6 -0.01587 0.26551 -0.060 0.9524
## afdec6 -0.54680 0.28721 -1.904 0.0593 .
## nov -0.15061 0.18997 -0.793 0.4294
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5983 on 123 degrees of freedom
## Multiple R-squared: 0.3084, Adjusted R-squared: 0.269
## F-statistic: 7.835 on 7 and 123 DF, p-value: 7.839e-08
model12 <- lm(lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 + afdec6 + dec, data = data)
a <- summary(model12)
a
##
## Call:
## lm(formula = lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 +
## afdec6 + dec, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.02927 -0.39735 0.04348 0.40190 1.52884
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -11.93762 21.72657 -0.549 0.5837
## lchempi 3.13171 0.47909 6.537 1.5e-09 ***
## lgas -0.06033 0.93690 -0.064 0.9488
## lrtwex 0.96522 0.40024 2.412 0.0174 *
## befile6 0.07460 0.26118 0.286 0.7757
## affile6 -0.05997 0.26537 -0.226 0.8216
## afdec6 -0.59802 0.28727 -2.082 0.0394 *
## dec 0.21112 0.19617 1.076 0.2839
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.597 on 123 degrees of freedom
## Multiple R-squared: 0.3113, Adjusted R-squared: 0.2722
## F-statistic: 7.944 on 7 and 123 DF, p-value: 6.164e-08