0% found this document useful (0 votes)
3 views12 pages

Unit Root Assignment

The document outlines a unit root assignment using R, focusing on the analysis of two time series datasets, 'li' and 'lw', from the 'Raotbl3' dataset. It includes visualizations of the time series, performs Augmented Dickey-Fuller tests for unit roots, and presents results from both the ADF and Phillips-Perron tests. The findings indicate the presence of unit roots in the datasets, which is crucial for understanding their stationarity properties.

Uploaded by

ali2468imran
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views12 pages

Unit Root Assignment

The document outlines a unit root assignment using R, focusing on the analysis of two time series datasets, 'li' and 'lw', from the 'Raotbl3' dataset. It includes visualizations of the time series, performs Augmented Dickey-Fuller tests for unit roots, and presents results from both the ADF and Phillips-Perron tests. The findings indicate the presence of unit roots in the datasets, which is crucial for understanding their stationarity properties.

Uploaded by

ali2468imran
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Unitroot assignment

Ali Imran
2026-02-24
library(urca)
data("Raotbl3")
li<-Raotbl3$li
lw<-Raotbl3$lw
plot(li,type="l",lwd=3)

plot(lw,type="l",lwd=3)
lit<-ts(li,start=c(1966), frequency=4)
lit

## Qtr1 Qtr2 Qtr3 Qtr4


## 1966 10.5821 10.5800 10.5990 10.6262
## 1967 10.6145 10.6307 10.6316 10.6132
## 1968 10.6141 10.6263 10.6366 10.6313
## 1969 10.6324 10.6361 10.6795 10.6813
## 1970 10.6801 10.6533 10.6839 10.6889
## 1971 10.7025 10.7212 10.7818 10.7641
## 1972 10.7841 10.8045 10.8230 10.8319
## 1973 10.8380 10.8097 10.7928 10.8310
## 1974 10.8328 10.8527 10.8089 10.8202
## 1975 10.8069 10.8196 10.8046 10.8372
## 1976 10.8123 10.7842 10.7713 10.7904
## 1977 10.8369 10.8333 10.8635 10.8884
## 1978 10.8924 10.9017 10.9108 10.9166
## 1979 10.9673 10.9324 10.9344 10.9506
## 1980 10.9465 10.9488 10.9294 10.9248
## 1981 10.9326 10.9202 10.9373 10.9269
## 1982 10.9315 10.9399 10.9599 10.9563
## 1983 10.9637 10.9703 10.9778 10.9801
## 1984 10.9942 10.9840 11.0120 11.0120
## 1985 11.0237 11.0300 11.0624 11.0556
## 1986 11.0644 11.0618 11.0839 11.0944
## 1987 11.1095 11.1116 11.1413 11.1507
## 1988 11.1680 11.1713 11.2032 11.2009
## 1989 11.2064 11.2160 11.2147 11.2286
## 1990 11.2352 11.2189 11.2276

lwt<-ts(lw,start=c(1966), frequency=4)
lwt

## Qtr1 Qtr2 Qtr3 Qtr4


## 1966 12.9481 12.9895 13.0115 13.0411
## 1967 13.0357 13.0518 13.0839 13.1120
## 1968 13.1183 13.1144 13.1009 13.0882
## 1969 13.0402 13.0391 13.0417 13.0261
## 1970 13.0032 13.0364 13.0461 13.0850
## 1971 13.1107 13.1241 13.1605 13.1748
## 1972 13.1612 13.1050 13.1082 13.1059
## 1973 13.0140 12.9301 12.8427 12.7710
## 1974 12.7281 12.7692 12.7492 12.7664
## 1975 12.7554 12.7605 12.7471 12.7238
## 1976 12.7156 12.7555 12.7517 12.8018
## 1977 12.8388 12.8438 12.8540 12.8618
## 1978 12.8491 12.9232 12.9022 12.8737
## 1979 12.8467 12.8647 12.8885 12.9183
## 1980 12.9277 12.9505 12.9615 12.9147
## 1981 12.9527 12.9641 12.9780 13.0299
## 1982 13.0604 13.1031 13.1577 13.1504
## 1983 13.1805 13.2245 13.1852 13.2298
## 1984 13.2849 13.2999 13.2904 13.3140
## 1985 13.3606 13.4574 13.4655 13.4371
## 1986 13.5020 13.5914 13.6804 13.7131
## 1987 13.5633 13.5814 13.6171 13.6201
## 1988 13.6460 13.6731 13.6884 13.7211
## 1989 13.7686 13.6833 13.7130 13.6225
## 1990 13.6957 13.7723 13.7424

[Link](lit, lwd=3)
[Link](lwt, lwd=3)
library(urca)

## ADF-test
??[Link]

## starting httpd help server ... done

dftestli<-[Link](lit,type="drift", selectlags="AIC")
summary(dftestli)

##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = [Link] ~ [Link].1 + 1 + [Link])
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.048016 -0.008572 0.000787 0.008549 0.055944
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.025583 0.113089 0.226 0.8215
## [Link].1 -0.001622 0.010387 -0.156 0.8762
## [Link] -0.189110 0.101435 -1.864 0.0654 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.01802 on 94 degrees of freedom
## Multiple R-squared: 0.03656, Adjusted R-squared: 0.01607
## F-statistic: 1.784 on 2 and 94 DF, p-value: 0.1736
##
##
## Value of test-statistic is: -0.1562 8.3001
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.51 -2.89 -2.58
## phi1 6.70 4.71 3.86

lid<-diff(lit)
plot(lid, lwd=3)
dftestlw<-[Link](lwt,type="drift", selectlags="AIC")
summary(dftestlw)

##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = [Link] ~ [Link].1 + 1 + [Link])
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.164350 -0.019130 0.002451 0.025201 0.081875
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.045792 0.190919 -0.240 0.8110
## [Link].1 0.003958 0.014549 0.272 0.7862
## [Link] 0.185606 0.103953 1.785 0.0774 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04204 on 94 degrees of freedom
## Multiple R-squared: 0.03754, Adjusted R-squared: 0.01706
## F-statistic: 1.833 on 2 and 94 DF, p-value: 0.1656
##
##
## Value of test-statistic is: 0.272 1.0282
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.51 -2.89 -2.58
## phi1 6.70 4.71 3.86

lwd<-diff(lwt)
plot(lwd, lwd=3)

dftestli2<-[Link](lit,type="trend", selectlags="AIC")
summary(dftestli2)

##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = [Link] ~ [Link].1 + 1 + tt + [Link])
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.042055 -0.009855 0.000914 0.010164 0.056374
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.1109930 0.5475952 2.029 0.0453 *
## [Link].1 -0.1043458 0.0517625 -2.016 0.0467 *
## tt 0.0006596 0.0003258 2.024 0.0458 *
## [Link] -0.1371550 0.1030505 -1.331 0.1865
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.01773 on 93 degrees of freedom
## Multiple R-squared: 0.07723, Adjusted R-squared: 0.04746
## F-statistic: 2.594 on 3 and 93 DF, p-value: 0.05719
##
##
## Value of test-statistic is: -2.0159 7.0818 2.0616
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.04 -3.45 -3.15
## phi2 6.50 4.88 4.16
## phi3 8.73 6.49 5.47

dftestlw2<-[Link](lwt,type="trend", selectlags="AIC")
summary(dftestlw2)

##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = [Link] ~ [Link].1 + 1 + tt + [Link])
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.16349 -0.02124 0.00794 0.02984 0.07657
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.2403229 0.2426179 0.991 0.3245
## [Link].1 -0.0192656 0.0189755 -1.015 0.3126
## tt 0.0003796 0.0002028 1.872 0.0643 .
## [Link] 0.1734590 0.1028001 1.687 0.0949 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04149 on 93 degrees of freedom
## Multiple R-squared: 0.07249, Adjusted R-squared: 0.04257
## F-statistic: 2.423 on 3 and 93 DF, p-value: 0.07078
##
##
## Value of test-statistic is: -1.0153 1.8719 1.7902
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.04 -3.45 -3.15
## phi2 6.50 4.88 4.16
## phi3 8.73 6.49 5.47

## PP-test
??[Link]
pptestli<-[Link](lit, type="Z-tau",model="trend", lags="long")
summary(pptestli)

##
## ##################################
## # Phillips-Perron Unit Root Test #
## ##################################
##
## Test regression with intercept and trend
##
##
## Call:
## lm(formula = y ~ y.l1 + trend)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.042682 -0.010770 -0.000481 0.010978 0.054949
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.3323502 0.5441324 2.449 0.0162 *
## y.l1 0.8781954 0.0499916 17.567 <2e-16 ***
## trend 0.0007706 0.0003155 2.443 0.0164 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.01774 on 95 degrees of freedom
## Multiple R-squared: 0.9905, Adjusted R-squared: 0.9903
## F-statistic: 4947 on 2 and 95 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic, type: Z-tau is: -2.6412
##
## aux. Z statistics
## Z-tau-mu 1.8554
## Z-tau-beta 3.0671
##
## Critical values for Z statistics:
## 1pct 5pct 10pct
## critical values -4.053974 -3.455671 -3.153363

pptestlw<-[Link](lwt, type="Z-tau",model="trend", lags="long")


summary(pptestlw)

##
## ##################################
## # Phillips-Perron Unit Root Test #
## ##################################
##
## Test regression with intercept and trend
##
##
## Call:
## lm(formula = y ~ y.l1 + trend)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.162413 -0.018989 0.003984 0.028772 0.081940
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.1850002 0.2492998 0.742 0.4599
## y.l1 0.9865149 0.0189879 51.955 <2e-16 ***
## trend 0.0003582 0.0002015 1.778 0.0786 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04198 on 95 degrees of freedom
## Multiple R-squared: 0.9817, Adjusted R-squared: 0.9813
## F-statistic: 2552 on 2 and 95 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic, type: Z-tau is: -0.9743
##
## aux. Z statistics
## Z-tau-mu 0.1917
## Z-tau-beta 2.0091
##
## Critical values for Z statistics:
## 1pct 5pct 10pct
## critical values -4.053974 -3.455671 -3.153363

pptestli2<-[Link](lit,type="Z-tau",model="constant", lags="long")
summary(pptestli2)
##
## ##################################
## # Phillips-Perron Unit Root Test #
## ##################################
##
## Test regression with intercept
##
##
## Call:
## lm(formula = y ~ y.l1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.050463 -0.009215 0.000469 0.010367 0.053650
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.03035 0.11206 0.271 0.787
## y.l1 0.99782 0.01029 96.961 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.01819 on 96 degrees of freedom
## Multiple R-squared: 0.9899, Adjusted R-squared: 0.9898
## F-statistic: 9401 on 1 and 96 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic, type: Z-tau is: -0.1024
##
## aux. Z statistics
## Z-tau-mu 0.1702
##
## Critical values for Z statistics:
## 1pct 5pct 10pct
## critical values -3.49776 -2.890909 -2.58224

pptestlw2<-[Link](lwt, type="Z-tau",model="trend", lags="long")


summary(pptestlw2)

##
## ##################################
## # Phillips-Perron Unit Root Test #
## ##################################
##
## Test regression with intercept and trend
##
##
## Call:
## lm(formula = y ~ y.l1 + trend)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.162413 -0.018989 0.003984 0.028772 0.081940
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.1850002 0.2492998 0.742 0.4599
## y.l1 0.9865149 0.0189879 51.955 <2e-16 ***
## trend 0.0003582 0.0002015 1.778 0.0786 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04198 on 95 degrees of freedom
## Multiple R-squared: 0.9817, Adjusted R-squared: 0.9813
## F-statistic: 2552 on 2 and 95 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic, type: Z-tau is: -0.9743
##
## aux. Z statistics
## Z-tau-mu 0.1917
## Z-tau-beta 2.0091
##
## Critical values for Z statistics:
## 1pct 5pct 10pct
## critical values -4.053974 -3.455671 -3.153363

You might also like