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_weibull (g07be)

Purpose

nag_univar_estim_weibull (g07be) computes maximum likelihood estimates for parameters of the Weibull distribution from data which may be right-censored.

Syntax

[beta, gamma, sebeta, segam, corr, dev, nit, ifail] = g07be(cens, x, ic, gamma, tol, maxit, 'n', n)
[beta, gamma, sebeta, segam, corr, dev, nit, ifail] = nag_univar_estim_weibull(cens, x, ic, gamma, tol, maxit, 'n', n)

Description

nag_univar_estim_weibull (g07be) computes maximum likelihood estimates of the parameters of the Weibull distribution from exact or right-censored data.
For nn realisations, yiyi, from a Weibull distribution a value xixi is observed such that
xiyi.
xiyi.
There are two situations:
(a) exactly specified observations, when xi = yixi=yi
(b) right-censored observations, known by a lower bound, when xi < yixi<yi.
The probability density function of the Weibull distribution, and hence the contribution of an exactly specified observation to the likelihood, is given by:
f(x ; λ,γ) = λγxγ1exp(λxγ),  x > 0,   for ​λ,γ > 0;
f(x;λ,γ)=λγxγ-1exp(-λxγ),  x>0,   for ​λ,γ>0;
while the survival function of the Weibull distribution, and hence the contribution of a right-censored observation to the likelihood, is given by:
S(x ; λ,γ) = exp(λxγ),   x > 0,   for ​ λ ,γ > 0.
S(x;λ,γ)=exp(-λ xγ),   x> 0,   for ​ λ ,γ> 0.
If dd of the nn observations are exactly specified and indicated by iDiD and the remaining (nd)(n-d) are right-censored, then the likelihood function, Like ​(λ,γ)Like ​(λ,γ) is given by
Like(λ,γ) ∝ (λγ)d (∏i ∈ Dxiγ − 1)
exp( n ) − λ ∑ xiγ i = 1
.
Like(λ,γ)(λγ)d (iDxiγ-1) exp(-λi=1nxiγ) .
To avoid possible numerical instability a different parameterisation β,γβ,γ is used, with β = log(λ)β=log(λ). The kernel log-likelihood function, L(β,γ)L(β,γ), is then:
n
L(β,γ) = dlog(γ) + dβ + (γ1)iDlog(xi)eβxiγ.
i = 1
L(β,γ)=dlog(γ)+dβ+(γ-1)iDlog(xi)-eβi=1nxiγ.
If the derivatives (L)/(β) L β , (L)/(γ) L γ , (2L)/(β2) 2L β2 , (2L)/(β γ) 2L β γ  and (2L)/(γ2) 2L γ2  are denoted by L1L1, L2L2, L11L11, L12L12 and L22L22, respectively, then the maximum likelihood estimates, β̂β^ and γ̂γ^, are the solution to the equations:
L1(β̂,γ̂) = 0
L1(β^,γ^)=0
(1)
and
L2(β̂,γ̂) = 0
L2(β^,γ^)=0
(2)
Estimates of the asymptotic standard errors of β̂β^ and γ̂γ^ are given by:
se(β̂) = sqrt((L22)/(L11L22L122)),  se(γ̂) = sqrt((L11)/(L11L22L122)).
se(β^)=-L22 L11L22-L122 ,  se(γ^)=-L11 L11L22-L122 .
An estimate of the correlation coefficient of β̂β^ and γ̂γ^ is given by:
(L12)/(sqrt(L12L22)).
L12L12L22 .
Note:  if an estimate of the original parameter λλ is required, then
λ̂ = exp(β̂)  and  se(λ̂) = λ̂se(β̂).
λ^=exp(β^)  and  se(λ^)=λ^se(β^).
The equations (1) and (2) are solved by the Newton–Raphson iterative method with adjustments made to ensure that γ̂ > 0.0γ^>0.0.

References

Gross A J and Clark V A (1975) Survival Distributions: Reliability Applications in the Biomedical Sciences Wiley
Kalbfleisch J D and Prentice R L (1980) The Statistical Analysis of Failure Time Data Wiley

Parameters

Compulsory Input Parameters

1:     cens – string (length ≥ 1)
Indicates whether the data is censored or non-censored.
cens = 'N'cens='N'
Each observation is assumed to be exactly specified. ic is not referenced.
cens = 'C'cens='C'
Each observation is censored according to the value contained in ic(i)ici, for i = 1,2,,ni=1,2,,n.
Constraint: cens = 'N'cens='N' or 'C''C'.
2:     x(n) – double array
n, the dimension of the array, must satisfy the constraint n1n1.
x(i)xi contains the iith observation, xixi, for i = 1,2,,ni=1,2,,n.
Constraint: x(i) > 0.0xi>0.0, for i = 1,2,,ni=1,2,,n.
3:     ic( : :) – int64int32nag_int array
Note: the dimension of the array ic must be at least nn if cens = 'C'cens='C', and at least 11 otherwise.
If cens = 'C'cens='C', then ic(i)ici contains the censoring codes for the iith observation, for i = 1,2,,ni=1,2,,n.
If ic(i) = 0ici=0, the iith observation is exactly specified.
If ic(i) = 1ici=1, the iith observation is right-censored.
If cens = 'N'cens='N', then ic is not referenced.
Constraint: if cens = 'C'cens='C', then ic(i) = 0ici=0 or 11, for i = 1,2,,ni=1,2,,n.
4:     gamma – double scalar
Indicates whether an initial estimate of γγ is provided.
If gamma > 0.0gamma>0.0, it is taken as the initial estimate of γγ and an initial estimate of ββ is calculated from this value of γγ.
If gamma0.0gamma0.0, then initial estimates of γγ and ββ are calculated, internally, providing the data contains at least two distinct exact observations. (If there are only two distinct exact observations, then the largest observation must not be exactly specified.) See Section [Further Comments] for further details.
5:     tol – double scalar
The relative precision required for the final estimates of ββ and γγ. Convergence is assumed when the absolute relative changes in the estimates of both ββ and γγ are less than tol.
If tol = 0.0tol=0.0, then a relative precision of 0.0000050.000005 is used.
Constraint: machine precisiontol1.0machine precisiontol1.0 or tol = 0.0tol=0.0.
6:     maxit – int64int32nag_int scalar
The maximum number of iterations allowed.
If maxit0maxit0, then a value of 2525 is used.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array x.
nn, the number of observations.
Constraint: n1n1.

Input Parameters Omitted from the MATLAB Interface

wk

Output Parameters

1:     beta – double scalar
The maximum likelihood estimate, β̂β^, of ββ.
2:     gamma – double scalar
Contains the maximum likelihood estimate, γ̂γ^, of γγ.
3:     sebeta – double scalar
An estimate of the standard error of β̂β^.
4:     segam – double scalar
An estimate of the standard error of γ̂γ^.
5:     corr – double scalar
An estimate of the correlation between β̂β^ and γ̂γ^.
6:     dev – double scalar
The maximized kernel log-likelihood, L(β̂,γ̂)L(β^,γ^).
7:     nit – int64int32nag_int scalar
The number of iterations performed.
8:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,cens'N'cens'N' or 'C''C',
orn < 1n<1,
ortol < 0.0tol<0.0,
or0.0 < tol < machine precision0.0<tol<machine precision,
ortol > 1.0tol>1.0.
  ifail = 2ifail=2
On entry,the iith observation, x(i)0.0xi0.0, for some i = 1,2,,ni=1,2,,n,
orthe iith censoring code, ic(i)0ici0 or 11, for some i = 1,2,,ni=1,2,,n and cens = 'C'cens='C'.
  ifail = 3ifail=3
On entry, there are no exactly specified observations, or the function was requested to calculate initial values and there are either less than two distinct exactly specified observations or there are exactly two and the largest observation is one of the exact observations.
  ifail = 4ifail=4
The method has failed to converge in maxit iterations. You should increase tol or maxit.
  ifail = 5ifail=5
Process has diverged. The process is deemed divergent if three successive increments of ββ or γγ increase or if the Hessian matrix of the Newton–Raphson process is singular. Either different initial estimates should be provided or the data should be checked to see if the Weibull distribution is appropriate.
  ifail = 6ifail=6
A potential overflow has been detected. This is an unlikely exit usually caused by a large input estimate of γγ.

Accuracy

Given that the Weibull distribution is a suitable model for the data and that the initial values are reasonable the convergence to the required accuracy, indicated by tol, should be achieved.

Further Comments

The initial estimate of γγ is found by calculating a Kaplan–Meier estimate of the survival function, (x)S^(x), and estimating the gradient of the plot of log(log((x)))log(-log(S^(x))) against xx. This requires the Kaplan–Meier estimate to have at least two distinct points.
The initial estimate of β̂β^, given a value of γ̂γ^, is calculated as
β̂ = log(d/(i = 1nxiγ̂)) .
β^=log(di=1nxiγ^ ) .

Example

function nag_univar_estim_weibull_example
cens = 'No censor';
x = [1.1;
     1.4;
     1.3;
     1.7;
     1.9;
     1.8;
     1.6;
     2.2;
     1.7;
     2.7;
     4.1;
     1.8;
     1.5;
     1.2;
     1.4;
     3;
     1.7;
     2.3;
     1.6;
     2];
ic = [int64(0)];
gamma = 0;
tol = 0;
maxit = int64(0);
[beta, gammaOut, sebeta, segam, corr, dev, nit, ifail] = ...
    nag_univar_estim_weibull(cens, x, ic, gamma, tol, maxit)
 

beta =

   -2.1073


gammaOut =

    2.7870


sebeta =

    0.4627


segam =

    0.4273


corr =

   -0.8755


dev =

  -20.5864


nit =

                    5


ifail =

                    0


function g07be_example
cens = 'No censor';
x = [1.1;
     1.4;
     1.3;
     1.7;
     1.9;
     1.8;
     1.6;
     2.2;
     1.7;
     2.7;
     4.1;
     1.8;
     1.5;
     1.2;
     1.4;
     3;
     1.7;
     2.3;
     1.6;
     2];
ic = [int64(0)];
gamma = 0;
tol = 0;
maxit = int64(0);
[beta, gammaOut, sebeta, segam, corr, dev, nit, ifail] = g07be(cens, x, ic, gamma, tol, maxit)
 

beta =

   -2.1073


gammaOut =

    2.7870


sebeta =

    0.4627


segam =

    0.4273


corr =

   -0.8755


dev =

  -20.5864


nit =

                    5


ifail =

                    0



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–2013