Learn R Programming

bssm (version 0.1.8)

svm: Stochastic Volatility Model

Description

Constructs a simple stochastic volatility model with Gaussian errors and first order autoregressive signal.

Usage

svm(y, rho, sd_ar, sigma, mu)

Arguments

y

Vector or a ts object of observations.

rho

prior for autoregressive coefficient.

sd_ar

Prior for the standard deviation of noise of the AR-process.

sigma

Prior for sigma parameter of observation equation.

mu

Prior for mu parameter of transition equation. Ignored if sigma is provided.

Value

Object of class svm or svm2.

Examples

Run this code
# NOT RUN {
data("exchange")
exchange <- exchange[1:100] # faster CRAN check
model <- svm(exchange, rho = uniform(0.98,-0.999,0.999),
 sd_ar = halfnormal(0.15, 5), sigma = halfnormal(0.6, 2))

obj <- function(pars) {
   -logLik(svm(exchange, rho = uniform(pars[1],-0.999,0.999),
   sd_ar = halfnormal(pars[2],sd=5),
   sigma = halfnormal(pars[3],sd=2)), nsim_states = 0)
}
opt <- nlminb(c(0.98, 0.15, 0.6), obj, lower = c(-0.999, 1e-4, 1e-4), upper = c(0.999,10,10))
pars <- opt$par
model <- svm(exchange, rho = uniform(pars[1],-0.999,0.999),
  sd_ar = halfnormal(pars[2],sd=5),
  sigma = halfnormal(pars[3],sd=2))

# }

Run the code above in your browser using DataLab