# NOT RUN {
## Get the data
library("Quandl")
d <- Quandl("NASDAQOMX/OMXS30", start_date="2012-01-02",
end_date="2014-01-02", type="zoo")
y <- as.numeric(100 * diff(log(d$"Index Value")))
## Estimate the filtered state
res <- pmh_sv(y, c(0, 0.9, 0.2), nPart=500, T=500, nIter=1000,
stepSize=diag(c(0.05, 0.0002, 0.002)))
## Plot the estimate
par(mfrow=c(3,1))
hist(res$thhat[,1], main="", xlab=expression(mu),
ylab="marginal posterior", freq=FALSE)
hist(res$thhat[,2], main="", xlab=expression(phi),
ylab="marginal posterior", freq=FALSE)
hist(res$thhat[,3], main="", xlab=expression(sigma[v]),
ylab="marginal posterior", freq=FALSE)
# }
Run the code above in your browser using DataLab