Findalphabeta_gamma: Quantile difference when tuning 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 Gamma distribution. 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 1 and 5, with 90

Usage

1
Findalphabeta_gamma(pars, p5, p95)

Arguments

pars

the shape and rate parameters (in that order) of the 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 Gamma distribution over the precision and the 5/95 percentiles of the error.

Examples

1
2
3
4
5
6
7
8
require(actuar)
# Find the Gamma distribution over the precision corresponding to my prior belief of the error (1/sqrt(precision)) lying between p5=2, p95=10
initpars <- c(5,0.1)
hyp_pars <- optim(par=initpars,Findalphabeta_gamma, p5=1, p95=5)

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

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