I have a problem in where i generate m independent draws from a
binomial distribution,
say
draw1 = rbinom( m , size.a, prob.a )
then I need to use each draw to generate a beta distribution. So,
like using a beta prior, binomial likelihood, and obtain beta
posterior, m many times. I have not found out a way to vectorize
draws from a beta distribution, so I have an explicit for loop within
my code
for( i in 1: m ) {
beta.post = rbeta( 10000, draw1[i] + prior.constant , prior.constant
+ size.a - draw1[i] )
beta.post.mean[i] = mean(beta.post)
beta.post.median[i] = median(beta.post)
etc.. for other info
}
Is there a way to vectorize draws from an beta distribution?
UC Slug
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.