C2: Working with barium data

data <- barium
head(data,5)
##     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
##          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
##   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

When I add the time trend to equation 10.22, there is only one significant variable - time trend variable.

model_1 <- lm(log(chnimp)~ log(chempi)+log(gas)+log(rtwex)+befile6+affile6+afdec6+t, data= data)
summary(model_1)
## 
## Call:
## lm(formula = log(chnimp) ~ log(chempi) + log(gas) + log(rtwex) + 
##     befile6 + affile6 + afdec6 + t, data = data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.94317 -0.31168  0.03172  0.36366  1.21218 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept) -2.367308  20.782159  -0.114  0.90949   
## log(chempi) -0.686233   1.239711  -0.554  0.58090   
## log(gas)     0.465669   0.876178   0.531  0.59605   
## log(rtwex)   0.078222   0.472440   0.166  0.86877   
## befile6      0.090470   0.251289   0.360  0.71945   
## affile6      0.097006   0.257313   0.377  0.70683   
## afdec6      -0.351502   0.282542  -1.244  0.21584   
## t            0.012706   0.003844   3.305  0.00124 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5748 on 123 degrees of freedom
## Multiple R-squared:  0.3616, Adjusted R-squared:  0.3252 
## F-statistic: 9.951 on 7 and 123 DF,  p-value: 8.358e-10

We have the Fstatistic = 10.99 > 7.158; Hence, the join effect of other variables are significant.

model_2 <- lm(log(chnimp)~ log(chempi)+log(gas)+log(rtwex)+befile6+affile6+afdec6, data= data)
summary(model_2)
## 
## Call:
## lm(formula = log(chnimp) ~ log(chempi) + log(gas) + log(rtwex) + 
##     befile6 + affile6 + afdec6, data = data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.03356 -0.39080  0.03048  0.40248  1.51720 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -17.80277   21.04537  -0.846   0.3992    
## log(chempi)   3.11719    0.47920   6.505 1.72e-09 ***
## log(gas)      0.19634    0.90662   0.217   0.8289    
## log(rtwex)    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
F= ((0.362 - 0.305)/1)/((1-0.362)/123)
F
## [1] 10.98903
critical_value = qf(0.95,1,123, TRUE)
critical_value
## [1] 7.157589

We have the Fstatistic = 0.8481 < 2.528; Hence, the join effect of monthly dummy variables are insignificant.

model_3 <- lm(log(chnimp)~ log(chempi)+log(gas)+log(rtwex)+befile6+affile6+afdec6+feb+mar+apr+may+jun+jul+aug+sep+oct+nov+dec, data= data)
summary(model_3)
## 
## Call:
## lm(formula = log(chnimp) ~ log(chempi) + log(gas) + log(rtwex) + 
##     befile6 + affile6 + afdec6 + feb + mar + apr + may + jun + 
##     jul + aug + sep + oct + nov + dec, data = data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.98535 -0.36207  0.07366  0.41786  1.37734 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 16.779215  32.428645   0.517   0.6059    
## log(chempi)  3.265062   0.492930   6.624 1.24e-09 ***
## log(gas)    -1.278140   1.389008  -0.920   0.3594    
## log(rtwex)   0.663045   0.471304   1.407   0.1622    
## befile6      0.139703   0.266808   0.524   0.6016    
## affile6      0.012632   0.278687   0.045   0.9639    
## afdec6      -0.521300   0.301950  -1.726   0.0870 .  
## feb         -0.417711   0.304444  -1.372   0.1728    
## mar          0.059052   0.264731   0.223   0.8239    
## apr         -0.451483   0.268386  -1.682   0.0953 .  
## may          0.033309   0.269242   0.124   0.9018    
## jun         -0.206332   0.269252  -0.766   0.4451    
## jul          0.003837   0.278767   0.014   0.9890    
## aug         -0.157064   0.277993  -0.565   0.5732    
## sep         -0.134161   0.267656  -0.501   0.6172    
## oct          0.051693   0.266851   0.194   0.8467    
## nov         -0.246260   0.262827  -0.937   0.3508    
## dec          0.132838   0.271423   0.489   0.6255    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6012 on 113 degrees of freedom
## Multiple R-squared:  0.3583, Adjusted R-squared:  0.2618 
## F-statistic: 3.712 on 17 and 113 DF,  p-value: 1.282e-05
F= ((0.358-0.305)/11)/((1-0.358)/113)
F
## [1] 0.84806
critical_value = qf(0.95,11,113, TRUE)
critical_value
## [1] 2.041383