data(denmark)
## Estimate an ARDL(3,1,3,2) model -------------------------------------
ardl_3132 <- ardl(LRM ~ LRY + IBO + IDE, data = denmark, order = c(3,1,3,2))
summary(ardl_3132)
## Add dummies or other variables that should stay fixed ---------------
d_74Q1_75Q3 <- ifelse(time(denmark) >= 1974 & time(denmark) <= 1975.5, 1, 0)
# the date can also be setted as below
d_74Q1_75Q3_ <- ifelse(time(denmark) >= "1974 Q1" & time(denmark) <= "1975 Q3", 1, 0)
identical(d_74Q1_75Q3, d_74Q1_75Q3_)
den <- cbind(denmark, d_74Q1_75Q3)
ardl_3132_d <- ardl(LRM ~ LRY + IBO + IDE | d_74Q1_75Q3,
data = den, order = c(3,1,3,2))
summary(ardl_3132_d)
compare <- data.frame(AIC = c(AIC(ardl_3132), AIC(ardl_3132_d)),
BIC = c(BIC(ardl_3132), BIC(ardl_3132_d)))
rownames(compare) <- c("no dummy", "with dummy")
compare
## Estimate an ARDL(3,1,3,2) model with a linear trend -----------------
ardl_3132_tr <- ardl(LRM ~ LRY + IBO + IDE + trend(LRM),
data = denmark, order = c(3,1,3,2))
# Alternative time trend specifications:
# time(LRM) 1974 + (0, 1, ..., 55)/4 time(data)
# trend(LRM) (1, 2, ..., 55)/4 (1:n)/freq
# trend(LRM, scale = FALSE) (1, 2, ..., 55) 1:n
## Subsample ARDL regression (start after 1975 Q4) ---------------------
ardl_3132_sub <- ardl(LRM ~ LRY + IBO + IDE, data = denmark,
order = c(3,1,3,2), start = "1975 Q4")
# the date can also be setted as below
ardl_3132_sub2 <- ardl(LRM ~ LRY + IBO + IDE, data = denmark,
order = c(3,1,3,2), start = c(1975,4))
identical(ardl_3132_sub, ardl_3132_sub2)
summary(ardl_3132_sub)
## Ease of use ---------------------------------------------------------
# The model specification of the ardl_3132 model can be created as easy as order=c(3,1,3,2)
# or else, it could be done using the dynlm package as:
library(dynlm)
m <- dynlm(LRM ~ L(LRM, 1) + L(LRM, 2) + L(LRM, 3) + LRY + L(LRY, 1) + IBO + L(IBO, 1) +
L(IBO, 2) + L(IBO, 3) + IDE + L(IDE, 1) + L(IDE, 2), data = denmark)
identical(m$coefficients, ardl_3132$coefficients)
# The full formula can be extracted from the ARDL model, and this is equal to
ardl_3132$full_formula
m2 <- dynlm(ardl_3132$full_formula, data = ardl_3132$data)
identical(m$coefficients, m2$coefficients)
Run the code above in your browser using DataLab