Learn R Programming

wle (version 0.9-91)

wle.gamma: Robust Estimation in the Gamma model

Description

wle.gamma is used to robust estimate the shape and the scale parameters via Weighted Likelihood, when the majority of the data are from a gamma distribution.

Usage

wle.gamma(x, boot=30, group, num.sol=1, raf="HD", smooth=0.008, tol=10^(-6), equal=10^(-3), max.iter=500, shape.int=c(0.01, 100), use.smooth=TRUE, tol.int, verbose=FALSE, maxiter=1000)

Arguments

x
a vector contain the observations.
boot
the number of starting points based on boostrap subsamples to use in the search of the roots.
group
the dimension of the bootstap subsamples. The default value is $max(round(size/4),var)$ where $size$ is the number of observations and $var$ is the number of variables.
num.sol
maximum number of roots to be searched.
raf
type of Residual adjustment function to be use:

raf="HD": Hellinger Distance RAF,

raf="NED": Negative Exponential Disparity RAF,

raf="SCHI2": Symmetric Chi-Squared Disparity RAF.

smooth
the value of the smoothing parameter.
tol
the absolute accuracy to be used to achieve convergence of the algorithm.
equal
the absolute value for which two roots are considered the same. (This parameter must be greater than tol).
max.iter
maximum number of iterations for the main function.
shape.int
a 2 dimension vector for the interval search of the shape parameter.
use.smooth
if FALSE the unsmoothed model is used. This is usefull when the integration routine does not work well.
tol.int
the absolute accuracy to be used in the integration routine. The default value is $tol*10^{-4}$.
verbose
if TRUE warnings are printed.
maxiter
maximum number of iterations. This value is passed to uniroot function.

Value

wle.gamma returns an object of class "wle.gamma".Only print method is implemented for this class.The object returned by wle.gamma are:
shape
the estimator of the shape parameter, one value for each root found.
scale
the estimator of the scale parameter, one value for each root found.
rate
the estimator of the rate parameter (1/scale), one value for each root found.
tot.weights
the sum of the weights divide by the number of observations, one value for each root found.
weights
the weights associated to each observation, one column vector for each root found.
f.density
the non-parametric density estimation.
m.density
the smoothed model.
delta
the Pearson residuals.
call
the match.call().
tot.sol
the number of solutions found.
not.conv
the number of starting points that does not converge after the max.iter iteration are reached.

Details

The gamma is parametrized as follows ($\alpha = scale$, $\omega = shape$):

$f(x) = 1/(\alpha^\omega Gamma(\omega)) x^(\omega-1) e^-(x/\alpha)$

for $x > 0$, $\alpha > 0$ and $\omega > 0$.

The function use uniroot to solve the estimating equation for $shape$, errors from uniroot are handled by try. If errors occurs then the function returns NA.

You can use shape.int to avoid them. It also use a fortran routine (dqagp) to calculate the smoothed model, i.e., evaluate the integral. Sometime the accuracy is not satisfactory, you can use use.smooth=FALSE to have an approximate estimation using the model instead of the smoothed model.

The Folded Normal distribution is use as kernel. The bandwith is $smooth*shape/scale^2$.

References

Markatou, M., Basu, A. and Lindsay, B.G., (1998). Weighted likelihood estimating equations with a bootstrap root search, Journal of the American Statistical Association, 93, 740-750.

Agostinelli, C., (1998). Inferenza statistica robusta basata sulla funzione di verosimiglianza pesata: alcuni sviluppi, Ph.D Thesis, Department of Statistics, University of Padova.

Examples

Run this code
library(wle)

x <- rgamma(n=100, shape=2, scale=2)

wle.gamma(x)

x <- c(rgamma(n=30, shape=2, scale=2), rgamma(n=100, shape=20, scale=20))

wle.gamma(x, boot=10, group=10, num.sol=2) # depending on the sample, one or two roots.  

Run the code above in your browser using DataLab