search for: mugrid

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

Did you mean: mgrid
2007 Mar 05
1
error message when using outer function
...in, Stern, and Rubin's Bayesian Data Analysis solutions, problem 3.5. I was trying to modify this code in post.a2 when I ran into this error. post.a1 <- function(mu,sd,y){ ldens <- 0 for (i in 1:length(y)) ldens <- ldens + log(dnorm(y[i],mu,sd)) ldens} y <- c(10,10,12,11,9) mugrid <- c(10,11) sdgrid <- c(1,1.2) logdens1 <- outer (mugrid, sdgrid, post.a1, y) #*** no error messages *** post.a2 <- function(mu,sd,y) { ldens <- sum(log(dnorm(y,mu,sd))) ldens } y <- c(10,10,12,11,9) mugrid <- c(10,11) sdgrid <- c(1,1.2) logdens2 <- outer (mugrid, s...