Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73678

returning values from .ado program

$
0
0
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:
:
gen myNewVar=betaParams .5 .2.
However, when I do this, I get: betaParams not found, r(111)

Any thoughts? Here's the 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




Viewing all articles
Browse latest Browse all 73678


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>