# Creates 10000 iterations in an AR(1) Markov chain with rho = .9
p <- 10000
tau <- 1
mc <- double(p)
mc[1] <- 2
for(i in 1:(p-1)){
mc[(i+1)] <- .9 * mc[i] + rnorm(1, 0, tau)
}
# Estimates the mean, .1 quantile and .9 quantile with MCSE using BM
mcse(mc)
mcse.q(mc, .1)
mcse.q(mc, .9)
# Estimates the mean, .1 quantile and .9 quantile with MCSE using OBM
mcse(mc, meth="OBM")
mcse.q(mc, .1, meth="OBM")
mcse.q(mc, .9, meth="OBM")
# Estimates E(x^2) with MCSE using spectral methods
g.fun <- function(x){x^2}
mcse(mc, g=g.fun, meth="TukeyHanning")
Run the code above in your browser using DataLab