search for: oldlogalpha

Displaying 1 result from an estimated 1 matches for "oldlogalpha".

2007 Jun 01
0
Metropolis code help
...rsion!) X<- cbind(1,DF$nsaid,DF$diuretic,DF$diuretic*DF$nsaid) y<- DF$Var3 Metropolis <- function(logtarget, start, R = 1000, sd = 1) { parmcount <- length(start) sims <- matrix(NA, nrow=R, ncol = parmcount) colnames(sims) <- names(start) sims[1,] <- start oldlogalpha <- logtarget(start) accepts <- 0 for (i in 2:R) { jump <- rnorm(parmcount, mean=0, sd=sd) y <- sims[i-1,] + jump newlogalpha <- logtarget(y) if (log(runif(1)) < newlogalpha - oldlogalpha) { sims[i,] <- y oldlogalpha <- newlogalpha accepts &lt...