## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.3'
## (as 'lib' is unspecified)
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.3'
## (as 'lib' is unspecified)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## Loading required package: zoo
## 
## 
## Attaching package: 'zoo'
## 
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
##     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
## Loading required package: carData
## 
## Attaching package: 'car'
## 
## The following object is masked from 'package:dplyr':
## 
##     recode
## 
## The following object is masked from 'package:purrr':
## 
##     some

(i) Add a linear time trend to equation (10.22)

##      chnimp           bchlimp         befile6          affile6      
##  Min.   :  39.68   Min.   : 8302   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.: 317.88   1st Qu.:13765   1st Qu.:0.0000   1st Qu.:0.0000  
##  Median : 535.72   Median :17716   Median :0.0000   Median :0.0000  
##  Mean   : 589.24   Mean   :19157   Mean   :0.0458   Mean   :0.0458  
##  3rd Qu.: 821.36   3rd Qu.:23646   3rd Qu.:0.0000   3rd Qu.:0.0000  
##  Max.   :1794.52   Max.   :45717   Max.   :1.0000   Max.   :1.0000  
##      afdec6          befile12         affile12         afdec12      
##  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.0000  
##  Median :0.0000   Median :0.0000   Median :0.0000   Median :0.0000  
##  Mean   :0.0458   Mean   :0.0916   Mean   :0.0916   Mean   :0.0916  
##  3rd Qu.:0.0000   3rd Qu.:0.0000   3rd Qu.:0.0000   3rd Qu.:0.0000  
##  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
##      chempi           gas                rtwex             spr        
##  Min.   :100.1   Min.   :6.900e+09   Min.   : 79.45   Min.   :0.0000  
##  1st Qu.:112.6   1st Qu.:8.210e+09   1st Qu.: 85.86   1st Qu.:0.0000  
##  Median :120.2   Median :8.520e+09   Median : 99.21   Median :0.0000  
##  Mean   :122.8   Mean   :8.519e+09   Mean   :102.50   Mean   :0.2519  
##  3rd Qu.:131.8   3rd Qu.:8.860e+09   3rd Qu.:116.38   3rd Qu.:0.5000  
##  Max.   :159.0   Max.   :1.020e+10   Max.   :146.45   Max.   :1.0000  
##       sum              fall           lchnimp           lgas      
##  Min.   :0.0000   Min.   :0.0000   Min.   :3.681   Min.   :22.65  
##  1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:5.762   1st Qu.:22.83  
##  Median :0.0000   Median :0.0000   Median :6.284   Median :22.87  
##  Mean   :0.2519   Mean   :0.2519   Mean   :6.175   Mean   :22.86  
##  3rd Qu.:0.5000   3rd Qu.:0.5000   3rd Qu.:6.711   3rd Qu.:22.90  
##  Max.   :1.0000   Max.   :1.0000   Max.   :7.492   Max.   :23.05  
##      lrtwex         lchempi            t              feb         
##  Min.   :4.375   Min.   :4.606   Min.   :  1.0   Min.   :0.00000  
##  1st Qu.:4.453   1st Qu.:4.724   1st Qu.: 33.5   1st Qu.:0.00000  
##  Median :4.597   Median :4.789   Median : 66.0   Median :0.00000  
##  Mean   :4.615   Mean   :4.804   Mean   : 66.0   Mean   :0.08397  
##  3rd Qu.:4.757   3rd Qu.:4.882   3rd Qu.: 98.5   3rd Qu.:0.00000  
##  Max.   :4.987   Max.   :5.069   Max.   :131.0   Max.   :1.00000  
##       mar               apr               may               jun         
##  Min.   :0.00000   Min.   :0.00000   Min.   :0.00000   Min.   :0.00000  
##  1st Qu.:0.00000   1st Qu.:0.00000   1st Qu.:0.00000   1st Qu.:0.00000  
##  Median :0.00000   Median :0.00000   Median :0.00000   Median :0.00000  
##  Mean   :0.08397   Mean   :0.08397   Mean   :0.08397   Mean   :0.08397  
##  3rd Qu.:0.00000   3rd Qu.:0.00000   3rd Qu.:0.00000   3rd Qu.:0.00000  
##  Max.   :1.00000   Max.   :1.00000   Max.   :1.00000   Max.   :1.00000  
##       jul               aug               sep               oct         
##  Min.   :0.00000   Min.   :0.00000   Min.   :0.00000   Min.   :0.00000  
##  1st Qu.:0.00000   1st Qu.:0.00000   1st Qu.:0.00000   1st Qu.:0.00000  
##  Median :0.00000   Median :0.00000   Median :0.00000   Median :0.00000  
##  Mean   :0.08397   Mean   :0.08397   Mean   :0.08397   Mean   :0.08397  
##  3rd Qu.:0.00000   3rd Qu.:0.00000   3rd Qu.:0.00000   3rd Qu.:0.00000  
##  Max.   :1.00000   Max.   :1.00000   Max.   :1.00000   Max.   :1.00000  
##       nov               dec             percchn       
##  Min.   :0.00000   Min.   :0.00000   Min.   : 0.1726  
##  1st Qu.:0.00000   1st Qu.:0.00000   1st Qu.: 1.8059  
##  Median :0.00000   Median :0.00000   Median : 2.7824  
##  Mean   :0.08397   Mean   :0.08397   Mean   : 3.2726  
##  3rd Qu.:0.00000   3rd Qu.:0.00000   3rd Qu.: 4.2495  
##  Max.   :1.00000   Max.   :1.00000   Max.   :10.2326
## 
## 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

(ii) Test for joint significance of all variables except the time trend

## 
## Call:
## lm(formula = log(chnimp) ~ poly(log(chempi), 2) + log(gas) + 
##     log(rtwex) + befile6 + affile6 + afdec6, data = data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.01477 -0.38667  0.02185  0.40410  1.48967 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           -2.04449   21.65600  -0.094   0.9249    
## poly(log(chempi), 2)1  4.02720    0.62067   6.489 1.91e-09 ***
## poly(log(chempi), 2)2  0.26912    0.69013   0.390   0.6972    
## log(gas)               0.15165    0.91692   0.165   0.8689    
## log(rtwex)             1.03473    0.42286   2.447   0.0158 *  
## befile6                0.06699    0.26256   0.255   0.7990    
## affile6               -0.02244    0.26643  -0.084   0.9330    
## afdec6                -0.56317    0.28687  -1.963   0.0519 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5994 on 123 degrees of freedom
## Multiple R-squared:  0.3057, Adjusted R-squared:  0.2662 
## F-statistic: 7.737 on 7 and 123 DF,  p-value: 9.737e-08

## [1] 34  8

(iii) Add monthly dummy variables and test for seasonality

## 
## Call:
## lm(formula = log(chnimp) ~ poly(log(chempi), 2) + 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.95723 -0.35273  0.07999  0.41126  1.33548 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           33.89513   33.26642   1.019   0.3104    
## poly(log(chempi), 2)1  4.22170    0.63826   6.614 1.33e-09 ***
## poly(log(chempi), 2)2  0.39128    0.69716   0.561   0.5757    
## log(gas)              -1.35522    1.39999  -0.968   0.3351    
## log(rtwex)             0.73640    0.49047   1.501   0.1361    
## befile6                0.15120    0.26840   0.563   0.5743    
## affile6                0.02663    0.28065   0.095   0.9246    
## afdec6                -0.51889    0.30290  -1.713   0.0895 .  
## feb                   -0.42928    0.30607  -1.403   0.1635    
## mar                    0.05476    0.26565   0.206   0.8370    
## apr                   -0.46008    0.26964  -1.706   0.0907 .  
## may                    0.02819    0.27022   0.104   0.9171    
## jun                   -0.21630    0.27065  -0.799   0.4259    
## jul                   -0.00404    0.27997  -0.014   0.9885    
## aug                   -0.16338    0.27907  -0.585   0.5594    
## sep                   -0.14124    0.26877  -0.526   0.6003    
## oct                    0.04562    0.26788   0.170   0.8651    
## nov                   -0.25463    0.26405  -0.964   0.3370    
## dec                    0.12592    0.27253   0.462   0.6449    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.603 on 112 degrees of freedom
## Multiple R-squared:  0.3601, Adjusted R-squared:  0.2573 
## F-statistic: 3.502 on 18 and 112 DF,  p-value: 2.278e-05