%GAMMAPARMS—Compute parameters for gamma distribution

Use this forum to post complete RATS "procedures". Please be sure to include instructions on using the procedure and detailed references where applicable.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

%GAMMAPARMS—Compute parameters for gamma distribution

Unread post by TomDoan »

This function returns a 2-vector (shape and scale in that order) with the two parameters for a gamma distribution which has a requested mean and standard deviation. The gamma can be used as a prior for a model parameter which has support on the positive reals (such as a variance), though the inverse gamma (http://www.estima.com/forum/viewtopic.php?f=7&t=1448) is a more common choice.
gammaparms.src
Function file
(1.07 KiB) Downloaded 836 times
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=%GammaParms(mean,sd)

Example

source gammaparms.src (needs to be done once)
compute gparms=%gammaparms(2.5,1.0)
set test 1 1000 = gparms(2)*%rangamma(gparms(1))
set logg 1 1000 = %loggammadensity(test,gparms(1),gparms(2))

will create a series named TEST with gammas with (population) mean 2.5 and standard deviation 1.0 and the log density (in LOGG) at each drawn value.
Post Reply