m1 <- rbind( c(1, 0.81, 0), c(1, 0.4972376, 0.4972376) )
testphi <- slMatrix( init = m1 )
m2 <- rbind( c(1, 0, 0), c(1, 0, 0) )
testtheta <- slMatrix( init = m2 )
## phi and theta are slMatrix here.
mo1 <- list(phi = testphi, theta = testtheta, p = 2, q = 2, period = 2)
set.seed(1234)
a1 <- sim_pc(mo1, 100)
## phi and theta are ordinary matrices here.
mo2 <- list(phi = m1[ , 2:ncol(m1)], theta = m2[ , 2:ncol(m2)], p = 2, q = 2, period = 2)
set.seed(1234)
a2 <- sim_pc(mo2, 100)
identical(a1, a2)
## Lina's PAR model
parcoef <- rbind(c(0.5, -0.06), c(0.6, -0.08),
c(0.7, -0.1), c(0.2, 0.15) )
picoef1 <- c(0.8, 1.25, 2, 0.5)
parcoef2 <- pi1ar2par(picoef1, parcoef)
picoef2 <- c(4, 0.25, 5, 0.2)
coefper2I2 <- pi1ar2par(picoef2, parcoef2)
#### specify the model using multi-companion approach
mc2I2 <- mcompanion::mc_from_filter(coefper2I2)
co2I2 <- eigen(mc2I2)$vectors
co2I2
m2I2 <- mcompanion::sim_pcfilter(period = 4, n.root = 4,
eigabs = c(1, 0.036568887, 0.001968887),
eigsign = c(1, 1, -1),
len.block = c(2, 1, 1),
type.eigval = c("r", "r", "r"),
co = cbind(co2I2[ ,1], rep(NA, 4), co2I2[,3:4]))
m2I2$pcfilter
perunit2mc <- sim_pc(list(phi = m2I2$pcfilter, p = 4, q = 0, period = 4), 500)
plot(perunit2mc)
plot(perunit2mc, type = "p")
# todo: give example with sigmat^2 !!!
Run the code above in your browser using DataLab