[R] Is there a way to not use an explicit loop?

2008-09-17 Thread Juancarlos Laguardia
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

Re: [R] Is There a way to not use an explicit loop?

2008-09-17 Thread Juancarlos Laguardia
Thanks to all who help out with this question.. Cut computation time by a fourth! Victor Hernando Cervantes Botero's idea work great. As well as Dan Davidson's __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEA

[R] trying to get rid of for loop in simple scenario

2009-03-02 Thread Juancarlos Laguardia
Hi, I have a problem in which i am having trouble vectorizing a snippet of my code to avoid a for loop. A basic example of what I'm trying to do is below. #simple example of problem x = c(1,1,3,3,6,7,8,8,9) # I create a vector that contains the unique values of x y = unique(x) y = c(1,3