# create model specification
spec <- CreateSpec()
# load data
data("SMI", package = "MSGARCH")
# fit the model on the data by MCMC
set.seed(123)
fit <- FitMCMC(spec = spec, data = SMI, ctr = list(nburn = 500L, nmcmc = 500L, nthin = 1L))
summary(fit)
# custom sampler example
if (FALSE) {
library("mcmc")
f_MCMC <- function(f_posterior, data, spec, par0, ctr){
par <- mcmc::metrop(f_posterior, initial = par0, nbatch = ctr$nmcmc + ctr$nburn,
data = data, spec = spec)$batch
colnames(par) = names(par0)
return(par)
}
set.seed(123)
fit <- FitMCMC(spec, data = SMI, ctr = list(SamplerFUN = f_MCMC,
nburn = 500L, nmcmc = 500L, nthin = 1L))
summary(fit)
}
Run the code above in your browser using DataLab