g07 Chapter Contents
NAG C Library Manual

# NAG Library Chapter Introductiong07 – Univariate Estimation

## 1  Scope of the Chapter

This chapter deals with the estimation of unknown arguments of a univariate distribution. It includes both point and interval estimation using maximum likelihood and robust methods.

## 2  Background to the Problems

Statistical inference is concerned with the making of inferences about a population using the observed part of the population called a sample. The population can usually be described using a probability model which will be written in terms of some unknown parameters. For example, the hours of relief given by a drug may be assumed to follow a Normal distribution with mean $\mu$ and variance ${\sigma }^{2}$; it is then required to make inferences about the arguments, $\mu$ and ${\sigma }^{2}$, on the basis of an observed sample of relief times.
There are two main aspects of statistical inference: the estimation of the arguments and the testing of hypotheses about the arguments. In the example above, the values of the argument ${\sigma }^{2}$ may be estimated and the hypothesis that $\mu \ge 3$ tested. This chapter is mainly concerned with estimation but the test of a hypothesis about an argument is often closely linked to its estimation. Tests of hypotheses which are not linked closely to estimation are given in the chapter on nonparametric statistics (Chapter g08).
There are two types of estimation to be considered in this chapter: point estimation and interval estimation. Point estimation is when a single value is obtained as the best estimate of the argument. However, as this estimate will be based on only one of a large number of possible samples, it can be seen that if a different sample were taken, a different estimate would be obtained. The distribution of the estimate across all the possible samples is known as the sampling distribution. The sampling distribution contains information on the performance of the estimator, and enables estimators to be compared. For example, a good estimator would have a sampling distribution with mean equal to the true value of the argument; that is, it should be an unbiased estimator; also the variance of the sampling distribution should be as small as possible. When considering a parameter estimate it is important to consider its variability as measured by its variance, or more often the square root of the variance, the standard error.
The sampling distribution can be used to find interval estimates or confidence intervals for the argument. A confidence interval is an interval calculated from the sample so that its distribution, as given by the sampling distribution, is such that it contains the true value of the argument with a certain probability.
Estimates will be functions of the observed sample and these functions are known as estimators. It is usually more convenient for the estimator to be based on statistics from the sample rather than all the individuals observations. If these statistics contain all the relevant information then they are known as sufficient statistics. There are several ways of obtaining the estimators; these include least squares, the method of moments, and maximum likelihood. Least squares estimation requires no knowledge of the distributional form of the error apart from its mean and variance matrix, whereas the method of maximum likelihood is mainly applicable to situations in which the true distribution is known apart from the values of a finite number of unknown arguments. Note that under the assumption of Normality, the least squares estimation is equivalent to the maximum likelihood estimation. Least squares is often used in regression analysis as described in Chapter g02, and maximum likelihood is described below.
Estimators derived from least squares or maximum likelihood will often be greatly affected by the presence of extreme or unusual observations. Estimators that are designed to be less affected are known as robust estimators.

### 2.1  Maximum Likelihood Estimation

Let ${X}_{i}$ be a univariate random variable with probability density function
 $fXixi;θ,$
where $\theta$ is a vector of length $p$ consisting of the unknown arguments. For example, a Normal distribution with mean ${\theta }_{1}$ and standard deviation ${\theta }_{2}$ has probability density function
 $12πθ2 exp-12 xi-θ1θ2 2 .$
The likelihood for a sample of $n$ independent observations is
 $Like=∏i=1nfXi xi;θ ,$
where ${x}_{i}$ is the observed value of ${X}_{i}$. If each ${X}_{i}$ has an identical distribution, this reduces to
 $Like=∏i=1nfX xi;θ ,$ (1)
and the log-likelihood is
 $logLike=L=∑i=1nlogfXxi;θ.$ (2)
The maximum likelihood estimates ($\stackrel{^}{\theta }$) of $\theta$ are the values of $\theta$ that maximize (1) and (2). If the range of $X$ is independent of the arguments, then $\stackrel{^}{\theta }$ can usually be found as the solution to
 $∑i=1n ∂∂θ^j logfXxi;θ^= ∂L ∂θ^j =0, j=1,2,…,p.$ (3)
Note that $\frac{\partial L}{\partial {\theta }_{j}}$ is known as the efficient score.
Maximum likelihood estimators possess several important properties.
(a) Maximum likelihood estimators are functions of the sufficient statistics.
(b) Maximum likelihood estimators are (under certain conditions) consistent. That is, the estimator converges in probability to the true value as the sample size increases. Note that for small samples the maximum likelihood estimator may be biased.
(c) For maximum likelihood estimators found as a solution to (3), subject to certain conditions, it follows that
 $E ∂L ∂θ =0,$ (4)
and
 $Iθ=-E ∂2L ∂θ2 =E ∂L ∂θ 2 ,$ (5)
and then that $\stackrel{^}{\theta }$ is asymptotically Normal with mean vector ${\theta }_{0}$ and variance-covariance matrix ${I}_{{\theta }_{0}}^{-1}$ where ${\theta }_{0}$ denotes the true value of $\theta$. The matrix ${I}_{\theta }$ is known as the information matrix and ${I}_{{\theta }_{0}}^{-1}$ is known as the Cramer–Rao lower bound for the variance of an estimator of $\theta$.
For example, if we consider a sample, ${x}_{1},{x}_{2},\dots ,{x}_{n}$, of size $n$ drawn from a Normal distribution with unknown mean $\mu$ and unknown variance ${\sigma }_{2}$ then we have
 $L=logLikeμ,σ2;x=-n2log2π-n2logσ2-∑i=1n xi-μ 2/2σ2$
and thus
 $∂L ∂μ =∑i= 1n xi-μ/σ2$
and
 $∂L ∂σ2 =-n2σ2 +∑i=1n xi-μ 2/2σ4.$
Then equating these two equations to zero and solving gives the maximum likelihood estimates
 $μ^=x-$
and
 $σ^2=∑i=1n xi-x- 2/n.$
These maximum likelihood estimates are asymptotically Normal with mean vector $a$, where
 $aT=μ,σ2,$
and covariance matrix $C$. To obtain $C$ we find the second derivatives of $L$ with respect to $\mu$ and ${\sigma }^{2}$ as follows:
 $∂2L ∂μ2 =- nσ2 ∂2L ∂σ22 = n2σ4 -∑i=1n xi-μ 2/σ6 ∂2L ∂μ∂σ2 = ∂2L ∂σ2∂μ =- nx--μσ4.$
Then
 $C-1=-E ∂2 L ∂μ2 ∂2 L ∂σ2∂μ ∂2 L ∂μ∂σ2 ∂2 L ∂σ22 = n/σ2 0 0 n/2σ4$
so that
 $C= σ2/n 0 0 2σ4/n .$
To obtain an estimate of $C$ the matrix may be evaluated at the maximum likelihood estimates.
It may not always be possible to find maximum likelihood estimates in a convenient closed form, and in these cases iterative numerical methods, such as the Newton–Raphson procedure or the EM algorithm (expectation maximization), will be necessary to compute the maximum likelihood estimates. Their asymptotic variances and covariances may then be found by substituting the estimates into the second derivatives. Note that it may be difficult to find the expected value of the second derivatives required for the variance-covariance matrix and in these cases the observed value of the second derivatives is often used.
The use of maximum likelihood estimation allows the construction of generalized likelihood ratio tests. If $\lambda =2\left({l}_{1}-{l}_{2}\right)$, where ${l}_{1}$ is the maximized log-likelihood function for a model $1$ and ${l}_{2}$ is the maximized log-likelihood function for a model $2$, then under the hypothesis that model $2$ is correct, $2\lambda$ is asymptotically distributed as a ${\chi }^{2}$ variable with $p-q$ degrees of freedom. Consider two models in which model $1$ has $p$ arguments and model $2$ is a sub-model (nested model) of model $1$ with $q arguments, that is model $1$ has an extra $p-q$ arguments. This result provides a useful method for performing hypothesis tests on the arguments. Alternatively, tests exist based on the asymptotic Normality of the estimator and the efficient score; see page 315 of Cox and Hinkley (1974).

### 2.2  Confidence Intervals

Suppose we can find a function, $t\left(x,\theta \right)$, whose distribution depends upon the sample $x$ but not on the unknown argument $\theta$, and which is a monotonic (say decreasing) function in $\theta$ for each $x$, then we can find ${t}_{1}$ such that $P\left({t}_{1}\le t\left(x,\theta \right)\right)=1-\alpha$ no matter what $\theta$ happens to be. The function $t\left(x,\theta \right)$ is known as a pivotal quantity. Since the function is monotonic the statement that ${t}_{1}\le t\left(x,\theta \right)$ may be rewritten as $\theta \ge {\theta }_{1}\left(x\right)$ see Figure 1. The statistic ${\theta }_{1}\left(x\right)$ will vary from sample to sample and if we assert that $\theta \ge {\theta }_{1}\left(x\right)$ for any sample values which arise, we will be right in a proportion $1-\alpha$ of the cases, in the long run or on average. We call ${\theta }_{1}\left(x\right)$ a $1-\alpha$ upper confidence limit for $\theta$.
Figure 1
We have considered only an upper confidence limit. The above idea may be generalized to a two-sided confidence interval where two quantities, ${t}_{0}$ and ${t}_{1}$, are found such that for all $\theta$, $\mathrm{P}\left({t}_{1}\le t\left(x,\theta \right)\le {t}_{0}\right)=1-\alpha$. This interval may be rewritten as ${\theta }_{0}\left(x\right)\le \theta \le {\theta }_{1}\left(x\right)$. Thus if we assert that $\theta$ lies in the interval [${\theta }_{0}\left(x\right),{\theta }_{1}\left(x\right)$] we will be right on average in $1-\alpha$ proportion of the times under repeated sampling.
Hypothesis (significance) tests on the arguments may be used to find these confidence limits. For example, if we observe a value, $k$, from a binomial distribution, with known argument $n$ and unknown argument $p$, then to find the lower confidence limit we find ${p}_{l}$ such that the probability that the null hypothesis ${H}_{0}$: $p={p}_{l}$ (against the one sided alternative that $p>{p}_{l}$) will be rejected, is less than or equal to $\alpha /2$. Thus for a binomial random variable, $B$, with arguments $n$ and ${p}_{l}$ we require that $P\left(B\ge k\right)\le \alpha /2$. The upper confidence limit, ${p}_{u}$, can be constructed in a similar way.
For large samples the asymptotic Normality of the maximum likelihood estimates discussed above is used to construct confidence intervals for the unknown arguments.

### 2.3  Robust Estimation

For particular cases the probability density function can be written as
 $fXixi;θ=1θ2g xi-θ1θ2$
for a suitable function $g$; then ${\theta }_{1}$ is known as a location argument and ${\theta }_{2}$, usually written as $\sigma$, is known as a scale argument. This is true of the Normal distribution.
If ${\theta }_{1}$ is a location argument, as described above, then equation (3) becomes
 $∑i=1nψ xi-θ^1σ^=0,$ (6)
where $\psi \left(z\right)=-\frac{d}{dz}\mathrm{log}\left(g\left(z\right)\right)$.
For the scale argument $\sigma$ (or ${\sigma }^{2}$) the equation is
 $∑i=1nχ xi-θ^1σ^=n/2,$ (7)
where $\chi \left(z\right)=z\psi \left(z\right)/2$.
For the Normal distribution $\psi \left(z\right)=z$ and $\chi \left(z\right)={z}^{2}/2$. Thus, the maximum likelihood estimates for ${\theta }_{1}$ and ${\sigma }^{2}$ are the sample mean and variance with the $n$ divisor respectively. As the latter is biased, (7) can be replaced by
 $∑i=1nχ xi-θ^1σ^=n-1β,$ (8)
where $\beta$ is a suitable constant, which for the Normal $\chi$ function is $\frac{1}{2}$.
The influence of an observation on the estimates depends on the form of the $\psi$ and $\chi$ functions. For a discussion of influence, see Hampel et al. (1986) and Huber (1981). The influence of extreme values can be reduced by bounding the values of the $\psi$- and $\chi$-functions. One suggestion due to Huber (1981) is
 $ψz= -C, ||z<-C z, z≤C C, ||z>C.$
Figure 2
Redescending $\psi$-functions are often considered; these give zero values to $\psi \left(z\right)$ for large positive or negative values of $z$. Hampel et al. (1986) suggested
 $ψz= -ψ-z z, 0≤z≤h1. h1, h1≤z≤h2. h1h3-z/h3-h2, h2≤z≤h3. 0, z>h3.$
Figure 3
Usually a $\chi$-function based on Huber's $\psi$-function is used: $\chi ={\psi }^{2}/2$. Estimators based on such bounded $\psi$-functions are known as $M$-estimators, and provide one type of robust estimator.
Other robust estimators for the location argument are
 (i) the sample median, (ii) the trimmed mean, i.e., the mean calculated after the extreme values have been removed from the sample, (iii) the winsorized mean, i.e., the mean calculated after the extreme values of the sample have been replaced by other more moderate values from the sample.
For the scale argument, alternative estimators are
 (i) the median absolute deviation scaled to produce an estimator which is unbiased in the case of data coming from a Normal distribution, (ii) the winsorized variance, i.e., the variance calculated after the extreme values of the sample have been replaced by other more moderate values from the sample.
For a general discussion of robust estimation, see Hampel et al. (1986) and Huber (1981).

### 2.4  Robust Confidence Intervals

In Section 2.2 it was shown how tests of hypotheses can be used to find confidence intervals. That approach uses a parametric test that requires the assumption that the data used in the computation of the confidence has a known distribution. As an alternative, a more robust confidence interval can be found by replacing the parametric test by a nonparametric test. In the case of the confidence interval for the location argument, a Wilcoxon test statistic can be used, and for the difference in location, computed from two samples, a Mann–Whitney test statistic can be used.

## 3  Recommendations on Choice and Use of Available Functions

Maximum Likelihood Estimation and Confidence Intervals
 nag_binomial_ci (g07aac) provides a confidence interval for the argument $p$ of the binomial distribution. nag_poisson_ci (g07abc) provides a confidence interval for the mean argument of the Poisson distribution. nag_censored_normal (g07bbc) provides maximum likelihood estimates and their standard errors for the arguments of the Normal distribution from grouped and/or censored data. nag_estim_weibull (g07bec) provides maximum likelihood estimates and their standard errors for the arguments of the Weibull distribution from data which may be right-censored. nag_estim_gen_pareto (g07bfc) provides maximum likelihood estimates and their standard errors for the parameters of the generalized Pareto distribution. nag_2_sample_t_test (g07cac) provides a $t$-test statistic to test for a difference in means between two Normal populations, together with a confidence interval for the difference between the means.
Robust Estimation
 nag_robust_m_estim_1var (g07dbc) provides $M$-estimates for location and, optionally, scale using four common forms of the $\psi$-function. nag_robust_m_estim_1var_usr (g07dcc) produces the $M$-estimates for location and, optionally, scale but for user-supplied $\psi$- and $\chi$-functions. nag_median_1var (g07dac) provides the sample median, median absolute deviation, and the scaled value of the median absolute deviation. nag_robust_trimmed_1var (g07ddc) provides the trimmed mean and winsorized mean together with estimates of their variance based on a winsorized variance.
Robust Internal Estimation
 nag_rank_ci_1var (g07eac) produces a rank based confidence interval for locations. nag_rank_ci_2var (g07ebc) produces a rank based confidence interval for the difference in location between two populations.
Outlier Detection
This chapter provides two functions for identifying potential outlying values, nag_outlier_peirce (g07gac) and nag_outlier_peirce_two_var (g07gbc). Many of the model fitting functions, for examples those in Chapters g02 and g13 also return vectors of residuals which can also be used to aid in the identification of outlying values.

## 4  Functionality Index

 2 sample t-test nag_2_sample_t_test (g07cac)
 Confidence intervals for parameters:
 binomial distribution nag_binomial_ci (g07aac)
 Poisson distribution nag_poisson_ci (g07abc)
 Maximum likelihood estimation of parameters:
 Normal distribution, grouped and/or censored data nag_censored_normal (g07bbc)
 Weibull distribution nag_estim_weibull (g07bec)
 Outlier detection:
 Peirce
 raw data or single variance supplied nag_outlier_peirce (g07gac)
 two variances supplied nag_outlier_peirce_two_var (g07gbc)
 Parameter estimates,
 generalized Pareto distribution nag_estim_gen_pareto (g07bfc)
 Robust estimation:
 confidence intervals:
 one sample nag_rank_ci_1var (g07eac)
 two samples nag_rank_ci_2var (g07ebc)
 median, median absolute deviation and robust standard deviation nag_median_1var (g07dac)
 M-estimates for location and scale parameters:
 standard weight functions nag_robust_m_estim_1var (g07dbc)
 trimmed and winsorized means and estimates of their variance nag_robust_trimmed_1var (g07ddc)
 user-defined weight functions nag_robust_m_estim_1var_usr (g07dcc)

None.

## 6  References

Cox D R and Hinkley D V (1974) Theoretical Statistics Chapman and Hall
Hampel F R, Ronchetti E M, Rousseeuw P J and Stahel W A (1986) Robust Statistics. The Approach Based on Influence Functions Wiley
Huber P J (1981) Robust Statistics Wiley
Kendall M G and Stuart A (1973) The Advanced Theory of Statistics (Volume 2) (3rd Edition) Griffin
Silvey S D (1975) Statistical Inference Chapman and Hall

g07 Chapter Contents