forked from helske/bssm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsvm.Rd
More file actions
49 lines (42 loc) · 1.62 KB
/
Copy pathsvm.Rd
File metadata and controls
49 lines (42 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/models.R
\name{svm}
\alias{svm}
\title{Stochastic Volatility Model}
\usage{
svm(y, mu, rho, sd_ar, sigma)
}
\arguments{
\item{y}{Vector or a \code{\link{ts}} object of observations.}
\item{mu}{Prior for mu parameter of transition equation.}
\item{rho}{prior for autoregressive coefficient.}
\item{sd_ar}{Prior for the standard deviation of noise of the AR-process.}
\item{sigma}{Prior for sigma parameter of observation equation, internally denoted as phi. Ignored
if \code{mu} is provided. Note that typically parametrization using mu is preferred due to
better numerical properties and availability of better Gaussian approximation.
Most notably the global approximation approach does not work with sigma parameterization as
sigma is not a parameter of the resulting approximate model.}
}
\value{
Object of class \code{svm}.
}
\description{
Constructs a simple stochastic volatility model with Gaussian errors and
first order autoregressive signal.
}
\examples{
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)), particles = 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))
}