* Variance Estimators for an MLE Electricity Costs Model
*
* Keywords:
* regression, mle, variance estimation
*
* Description:
* We illustrate how to estimate a model for Average Costs in Electricity
* Supply industry nonparametrically
* and plot it
*
* Author(s):
* Noel Roy
* Skif Pankov
*
* Source:
* William H. Greene, Econometric Analysis - 7th Edition
* Pearson International Edition, Chapter 14, Example 14.4 (page 562)
*
* Reading the data and naming variables, specifying to ignore the first
* line
read (TableFC-1.shd) i y x / list skiplines=1
* Doing the Maximum Likelihood Estimation of the model with non-normal errors
mle y x
* Testing the hypothesis that the coefficient on x is unity
test x=1
* Using nl command as a more general approach to maximum likelihood
* estimation, specifying to save standard errors in a variable sigma and
* (through logden option) that the equation given on the eq command
* is the log-density for a single observation
nl 1 /ncoef=1 logden genrvar stderr=sigma
eq -log(beta+x)-y/(beta+x)
end
* The default asymptotic variance as calculated is
gen1 sigma**2
* Calculating the three forms of the asymptotic variance of beta
* First, that based on the expectation of the hessian
genr ey=beta+x
genr v1=-1/(beta+x)**2+2*ey/(beta+x)**3
* Second, that based on the actual value of the hessian
genr v2=-1/(beta+x)**2+2*y/(beta+x)**3
* third, that based the outer product of the gradient
genr v3=(-1/(beta+x)+y/(beta+x)**2)**2
* Summing these values, and inverting
?stat v1-v3 /sums=varinv
matrix var=1/varinv
* print the three estimates.
print var
stop