search for: nrdraw

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

Did you mean: nrdraws
2011 Dec 03
2
density function always evaluating to zero
...del 0 # # # # # # # z <- x1^2 M <- sum(z^2) MI <- 1/M zy <- crossprod(z,y) alpha.ols <- MI * zy resid_m0 <- y - z * alpha.ols s2_m0 <- sum(resid_m0^2)/v # use gibbs sampler to sample from posterior densities n <- length(y) k <- 1 v <- n - k # set up gibbs sampler nrDraws <- 10000 h_sample_m0 <- rgamma(nrDraws, v/2, v*s2_m0/2) alpha_sample <- matrix(0, nrow = nrDraws, ncol = 1) for(i in 1:nrDraws) { alpha_sample[i] <- rnorm(1,alpha.ols,(1/h_sample_m0[i]) * MI) } # define posterior density for model 0 f <- function(alpha,h) { e <- y -...