*
* %InvGammaParms(mean,sd)
* returns a 2-vector (shape and scale in that order) with the two
* parameters for an inverse Gamma distribution with the given mean and
* standard deviation.
*
* If the s.d. is %NA (infinite), a is 2, which is the largest value of
* a for which the variance is undefined.
*
* Example:
*  source invgammaparms.src (needs to be done once)
*  compute igparms=%invgammaparms(2.0,1.0)
*  set test 1 1000 = igparms(2)/%rangamma(igparms(1))
*  set logg 1 1000 = -2.0*log(test)+$
*     %loggammadensity(1.0/test,igparms(1),1.0/igparms(2))
*
* will create a series named TEST with inverse gammas with (population)
* mean 2 and standard deviation 1 and the log density (in LOGG) at each
* drawn value.
*
* Revision Schedule:
*  07/2009 Written by Tom Doan, Estima.
*  05/2012 Corrected formula (had components backwards)
*
function %InvGammaParms mean sd
type vect[real] %InvGammaParms
type real mean
type real sd
*
local real a
compute a=%if(%valid(sd),(mean/sd)^2+2,2.0)
compute %InvGammaParms=||a,mean*(a-1)||
end


