%BETAPARMS—Compute parameters for a beta distribution
Posted: Mon May 07, 2012 1:58 pm
This function returns a 2-vector with the parameters for a beta distribution which has a requested mean and standard deviation. The beta is often used for the prior for a model parameter which has support on (0,1) and can be adapted easily to handle support on more general finite intervals.
Because it's a function (not a procedure), you need to do a SOURCE instruction on the file before you can use it in a RATS program.
target VECTOR=%BetaParms(mean,sd)
The mean must in the range (0,1) and the standard deviation in (0,sqrt(mean*(1-mean)))
Example
source betaparms.src (needs to be done once)
compute bparms=%BetaParms(.50,.20)
set test 1 1000 = %ranbeta(bparms(1),bparms(2))
set logg 1 1000 = %logbetadensity(test,bparms(1),bparms(2))
will create a series named TEST with beta draws with (population) mean .5 and standard deviation .2 and the log density (in LOGG) at each drawn value.
Because it's a function (not a procedure), you need to do a SOURCE instruction on the file before you can use it in a RATS program.
target VECTOR=%BetaParms(mean,sd)
The mean must in the range (0,1) and the standard deviation in (0,sqrt(mean*(1-mean)))
Example
source betaparms.src (needs to be done once)
compute bparms=%BetaParms(.50,.20)
set test 1 1000 = %ranbeta(bparms(1),bparms(2))
set logg 1 1000 = %logbetadensity(test,bparms(1),bparms(2))
will create a series named TEST with beta draws with (population) mean .5 and standard deviation .2 and the log density (in LOGG) at each drawn value.