Hi, all. I'm writing an ado script to generate probabilities from a beta distribution using the mean and standard deviation of the distribution rather than the alpha and beta values. The program calculates the results I'm looking for. However, I'm wrestling with returning results.
Ideally I'd be able to do something like:
However, when I do this, I get: betaParams not found, r(111)
Any thoughts? Here's the code.
Ideally I'd be able to do something like:
Code:
gen myNewVar=betaParams .5 .2.
Any thoughts? Here's the code.
Code:
cap program drop betaParams program betaParams version 14 args mean sd local constant=(`mean'*(1-`mean')/(`sd'^2))-1 local a=`mean'*`constant' local b=(1-`mean')*`constant' if (`a' <.05 | `b' <.15) { di as error "invalid parameters" exit 110 } di rbeta(`a', `b') end
Comment