Description Usage Arguments Value Examples
#### MCMC 3, multivariate normal distributed steps, each step is one p-dimensional vector from a multivariate normal distribution
1 | bceMCMC_mvrnorm(nmcmc, burn, thin, x, y, reg, step, priortheta)
|
nmcmc |
Number of mcmc samples to generate, before burning and thinning |
burn |
number of samples to burn |
thin |
keep only one of every 'thin' samples |
x |
predictors |
y |
response |
reg |
currently only option is "constant" |
step |
$(step^2)/p$ is multiplied by the identity matrix, which is then used as the covariance for a multivariate normal proposal density in the Metropolis Algorithm |
priortheta |
only currently only option is "Exp", "Higs" and "none" will also be implemented |
returns a list containing mcmc.ma (samples) and accept (acceptance rates)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | nsamp <- 100
burn <- 200
thin <- 10
n <- 10
x1 <- seq(-5,10,length.out = n)
x2 <- seq(0,15,length.out = n)
x <- expand.grid(x1,x2)
x <- as.matrix(x)
d2 <- c(0.01,0.2,0,0) #here we set the theta parameters to be 0.01 and 0.2.
# These are the modes of the distribution that we will sample from using MCMC
cor.par <- data.frame(matrix(data = d2,nrow = dim(x)[2],ncol = 2))
names(cor.par) <- c("Theta.y","Alpha.y")
R <- cor.matrix(x,cor.par) # obtain covariance matrix
L <- chol(R)
z <- as.matrix(rnorm(n^2))
y <- L%*%z
gp <- bceMCMC_mvrnorm(1000,10,10,x,y,reg = "constant",step =1, priortheta = "Exp")
mean(gp$mcmc.ma[,2]) #these means should be similar to the theta parameters set above
mean(gp$mcmc.ma[,1])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.