if(!requireNamespace("tseries") ||
!requireNamespace("urca")) {
if(interactive() || is.na(Sys.getenv("_R_CHECK_PACKAGE_NAME_", NA))) {
stop("not all packages required for the example are installed")
} else q() }
## data
data("PepperPrice", package = "AER")
plot(PepperPrice, plot.type = "single", col = 1:2)
## package
library("tseries")
library("urca")
## unit root tests
adf.test(log(PepperPrice[, "white"]))
adf.test(diff(log(PepperPrice[, "white"])))
pp.test(log(PepperPrice[, "white"]), type = "Z(t_alpha)")
pepper_ers <- ur.ers(log(PepperPrice[, "white"]),
type = "DF-GLS", model = "const", lag.max = 4)
summary(pepper_ers)
## stationarity tests
kpss.test(log(PepperPrice[, "white"]))
## cointegration
po.test(log(PepperPrice))
pepper_jo <- ca.jo(log(PepperPrice), ecdet = "const", type = "trace")
summary(pepper_jo)
pepper_jo2 <- ca.jo(log(PepperPrice), ecdet = "const", type = "eigen")
summary(pepper_jo2)
Run the code above in your browser using DataLab