search for: resid_m0

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

2011 Dec 03
2
density function always evaluating to zero
...nsity function always returns 0. How can I solve this problem? Here is my code #generate data x1 <- runif(100, min = -10, max = 10) y <- 2 * x1^2 + rnorm(100) # # # # # # # # Model 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...