if (FALSE) {
##
## Example 1: Fit a VAR(p) model to SOI/Recruitment series:
##
# Use this variable to set the VAR model order
p <- 5
data <- cbind(as.numeric(astsa::soi-mean(astsa::soi)),
as.numeric(astsa::rec-mean(astsa::rec)) / 50)
data <- apply(data, 2, function(x) x-mean(x))
# If you run the example be aware that this may take several minutes
print("example may take some time to run")
mcmc <- gibbs_var(data=data, ar.order=p, Ntotal=10000, burnin=4000, thin=2)
# Plot spectral estimate, credible regions and periodogram on log-scale
plot(mcmc, log=T)
##
## Example 2: Fit a VAR(p) model to VMA(1) data
##
# Use this variable to set the VAR model order
p <- 5
n <- 256
ma <- rbind(c(-0.75, 0.5), c(0.5, 0.75))
Sigma <- rbind(c(1, 0.5), c(0.5, 1))
data <- sim_varma(model=list(ma=ma), n=n, d=2)
data <- apply(data, 2, function(x) x-mean(x))
# If you run the example be aware that this may take several minutes
print("example may take some time to run")
mcmc <- gibbs_var(data=data, ar.order=p, Ntotal=10000, burnin=4000, thin=2)
# Plot spectral estimate, credible regions and periodogram on log-scale
plot(mcmc, log=T)
}
Run the code above in your browser using DataLab