# NOT RUN {
# load data
data("SMI", package = "MSGARCH")
# create model specification
# MS(2)-GARCH(1,1)-Normal (default)
spec <- CreateSpec()
# fit the model on the data by MCMC
set.seed(123)
fit <- FitMCMC(spec = spec, data = SMI, ctr = list(n.burn = 500L, n.mcmc = 500L, n.thin = 1L))
summary(fit)
# custom sampler example
# }
# NOT RUN {
library("mcmc")
f_MCMC <- function(f_posterior, data, spec, par0, ctr){
par <- mcmc::metrop(f_posterior, initial = par0, nbatch = ctr$n.mcmc + ctr$n.burn,
data = data, spec = spec)$batch
return(par)
}
set.seed(123)
fit <- FitMCMC(spec, data = SMI, ctr = list(SamplerFUN = f_MCMC,
n.burn = 500L, n.mcmc = 500L, n.thin = 1L))
summary(fit)
# }
Run the code above in your browser using DataLab