Findalphabeta_invgamma: Quantile difference when tuning inverse Gamma distribution...

Description Usage Arguments Value Examples

View source: R/genericfns.R

Description

This function returns the normalised difference between specified and required 5 and 95 percentiles of the inverse gamma distribution over the variance. The percentiles represent those of the required error, i.e. the root of the variance. For example, if the error of an observation is believed to be between 2 and 10, with 90

Usage

1
Findalphabeta_invgamma(pars, p5, p95)

Arguments

pars

the shape and scale parameters (in that order) of the inverse-Gamma distribution

p5

the 5 percentile of the desired error distribution

p95

the 95 percentils of the desired error distribution

Value

A numeric which is a measure of the discrepancy between the inverse-Gamma distribution and the 5/95 percentiles.

Examples

1
2
3
4
5
6
7
8
require(actuar)
# Find the an inverse-gamma distribution of the variance parameter corresponding to my prior belief of the error (sqrt(variance)) lying between p5=2, p95=10
initpars <- c(5,0.1)
hyp_pars <- optim(par=initpars,Findalphabeta_invgamma, p5=2, p95=10)

# Now simulate from an inverse Gamma with these parameters and verify quantiles
X <- rinvgamma(shape = hyp_pars$par[1], scale = hyp_pars$par[2],n=10000)
print( quantile( sqrt(X),c(0.05,0.95)))

shazhe/mvst0 documentation built on May 29, 2019, 9:20 p.m.