hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_univar_estim_genpareto (g07bf)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_univar_estim_genpareto (g07bf) estimates parameter values for the generalized Pareto distribution by using either moments or maximum likelihood.

Syntax

[xi, beta, asvc, obsvc, ll, ifail] = g07bf(y, optopt, 'n', n)
[xi, beta, asvc, obsvc, ll, ifail] = nag_univar_estim_genpareto(y, optopt, 'n', n)

Description

Let the distribution function of a set of n observations
yi ,   i=1,2,,n  
be given by the generalized Pareto distribution:
Fy = 1- 1+ ξy β -1/ξ , ξ0 1-e-yβ , ξ=0;  
where
Estimates ξ^ and β^ of the parameters ξ and β are calculated by using one of:
The variances and covariance of the asymptotic Normal distribution of parameter estimates ξ^ and β^ are returned if ξ^ satisfies:
If the MLE option is exercised, the observed variances and covariance of ξ^ and β^ is returned, given by the negative inverse Hessian of L.

References

Hosking J R M and Wallis J R (1987) Parameter and quantile estimation for the generalized Pareto distribution Technometrics 29(3)
McNeil A J, Frey R and Embrechts P (2005) Quantitative Risk Management Princeton University Press

Parameters

Compulsory Input Parameters

1:     yn – double array
The n observations yi, for i=1,2,,n, assumed to follow a generalized Pareto distribution.
Constraints:
  • yi0.0;
  • i=1 n yi>0.0.
2:     optopt int64int32nag_int scalar
Determines the method of estimation, set:
optopt=-2
For the method of probability-weighted moments.
optopt=-1
For the method of moments.
optopt=1
For maximum likelihood with starting values given by the method of moments estimates.
optopt=2
For maximum likelihood with starting values given by the method of probability-weighted moments.
Constraint: optopt=-2, -1, 1 or 2.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the dimension of the array y.
The number of observations.
Constraint: n>1.

Output Parameters

1:     xi – double scalar
The parameter estimate ξ^.
2:     beta – double scalar
The parameter estimate β^.
3:     asvc4 – double array
The variance-covariance of the asymptotic Normal distribution of ξ^ and β^. asvc1 contains the variance of ξ^; asvc4 contains the variance of β^; asvc2 and asvc3 contain the covariance of ξ^ and β^.
4:     obsvc4 – double array
If maximum likelihood estimates are requested, the observed variance-covariance of ξ^ and β^. obsvc1 contains the variance of ξ^; obsvc4 contains the variance of β^; obsvc2 and obsvc3 contain the covariance of ξ^ and β^.
5:     ll – double scalar
If maximum likelihood estimates are requested, ll contains the log-likelihood value L at the end of the optimization; otherwise ll is set to -1.0.
6:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

   ifail=1
Constraint: n>1.
   ifail=2
Constraint: yi0.0 for all i.
   ifail=3
Constraint: optopt=-2, -1, 1 or 2.
W  ifail=6
The asymptotic distribution is not available for the returned parameter estimates.
W  ifail=7
The distribution of maximum likelihood estimates cannot be calculated for the returned parameter estimates because the Hessian matrix could not be inverted.
W  ifail=8
The asymptotic distribution of parameter estimates is invalid and the distribution of maximum likelihood estimates cannot be calculated for the returned parameter estimates because the Hessian matrix could not be inverted.
   ifail=9
The optimization of log-likelihood failed to converge; no maximum likelihood estimates are returned. Try using the other maximum likelihood option by resetting optopt. If this also fails, moments-based estimates can be returned by an appropriate setting of optopt.
   ifail=10
Variance of data in y is too low for method of moments optimization.
   ifail=11
The sum of y is zero within machine precision.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

Not applicable.

Further Comments

The search for maximum likelihood parameter estimates is further restricted by requiring
1+ ξ^yi β^ > 0 ,  
as this avoids the possibility of making the log-likelihood L arbitrarily high.

Example

This example calculates parameter estimates for 23 observations assumed to be drawn from a generalized Pareto distribution.
function g07bf_example


fprintf('g07bf example results\n\n');

optopt = int64(2);

% Catch warnings for ifail=6,7,8
warn_state = nag_issue_warnings();
nag_issue_warnings(true);
wstat = warning();
warning('OFF');

y = [1.5800;  0.1390; 2.3624; 2.9435; 0.1363; 0.9688; 0.6585; 2.8011; ...
     0.9880;  1.7887; 0.0630; 0.3862; 1.5130; 0.0669; 1.3659; 0.4256; ...
     0.3485; 27.8760; 5.2503; 1.1028; 0.5273; 1.3189; 0.6490];

% Calculate the GPD parameter estimates
[xi, beta, asvc, obsvc, ll, ifail] = ...
  g07bf(y, optopt);

if ifail == 0 || (ifail > 5 && ifail < 9)
  % Display parameter estimates
  fprintf('xi             %14.6f\n', xi);
  fprintf('beta           %14.6f\n\n', beta);

  % Display Parameter Distributions
  if optopt > 0
    if (ifail == 7 || ifail == 8)
      fprintf('Invalid observed distribution\n');
    else
      fprintf('Observed distribution\n');
      fprintf('Var(xi)               %14.6f\n', obsvc(1));
      fprintf('Var(beta)             %14.6f\n', obsvc(4));
      fprintf('Covar(xi,beta)        %14.6f\n', obsvc(2));
      fprintf('Final log-likelihood: %14.6f\n\n', ll);
    end
  else
    if (ifail == 6 || ifail == 7)
      fprintf('Invalid asymptotic distribution\n');
    else
      fprintf('Asymptotic distribution\n');
      fprintf('Var(xi)        %14.6f\n', asvc(1));
      fprintf('Var(beta)      %14.6f\n', asvc(4));
      fprintf('Covar(xi,beta) %14.6f\n', asvc(2));
    end
  end
end

warning(wstat);

nag_issue_warnings(warn_state);


g07bf example results

xi                   0.540439
beta                 1.040549

Observed distribution
Var(xi)                     0.079932
Var(beta)                   0.119872
Covar(xi,beta)             -0.045509
Final log-likelihood:     -36.344327


PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015