Hi Nirmala,
Yes, I wrote a function that computes the probabilities for all possible
values of pi that I am concerned with (.01, .02, .03, ... 1.0). I wrote
these probabilities into the vector beta.prob (dependent upon mu and gamma).
Again, I'm not sure if there is a more efficient way to do this.
Then, I check to make sure that your probability distribution is a "real"
one in that sum(probability distribution)=1. I do this by
beta.prob <- beta.prob/sum(beta.prob)
to automatically normalize the probability distribution. I don't think it
will effect your results for drawing if you use a "non-normalized"
probability distribution, but it's not an "official" probability
distribution.
Did you also use the sample function to draw from your beta distribution?
John.
On 2/23/03 5:30 PM, "Nirmala Ravishankar" <ravishan(a)fas.harvard.edu>
wrote:
hey John,
What is beta.prob in your sample statement? Is it something generated
from rbeta, or did you write a function yourself. The reason I ask is, I
generated the beta function, but some of the probabilities tend to
infinity. Is that a problem?
-
On Sun, 23 Feb 2003, John Bright wrote:
Here's an R efficiency question.
The manner in which I am sampling from my beta distribution is via the
sample() function, where I define x to be a vector (.01,.02,.03, ... 1.0)
(the possible values of pi), and p the vector that contains the probability
values for each ordinate in the vector x. So, my sample function looks
something like:
pi <- sample(x=all.pi, n=N, replace=T, p=beta.prob)
Is there a different way to accomplish this that does not require
constructing the vectors of possible pi's and their corresponding
probabilities explicitly?
Thanks,
John.
_______________________________________________
gov2001-l mailing list
gov2001-l(a)fas.harvard.edu
http://www.fas.harvard.edu/mailman/listinfo/gov2001-l