* * Example 17.4 on page 482 * open data tablefd-1[1].txt data(format=prn,org=columns) 1 20 id y e * * There's one free parameter, which we'll call b * nonlin b * * We create a FRML which evaluates the log likelihood element for each * observation. * frml logl = -log(b+e)-y/(b+e) * * This estimates the model using the BHHH procedure. This is used not just for * computing the covariance matrix at the end, but is also used to estimate the * curvature at all iterations. * maximize(method=bhhh) logl compute bhhhvar=%stderrs(1)**2 * * This estimates the model using the BFGS procedure, which does computes an * estimate to the inverse of 2nd derivative of the log likelihood. This cannot be * started from a converged or almost converged settings for the parameters, as it * makes its estimate by seeing how the gradient changes from one iteration to * the next. If the gradient starts out at zero, this isn't possible. * compute b=0 maximize(method=bfgs) logl compute bfgsvar=%stderrs(1)**2 * * Computing the expected value of the 2nd derivative directly. * set logl2diff = 1.0/(b+e)**2-2*(b+e)/(b+e)**3 compute infovar=-1.0/%sum(logl2diff) * * And using the sample mean rather than the theoretical mean * set logl2diff = 1.0/(b+e)**2-2*y/(b+e)**3 compute ainfovar=-1.0/%sum(logl2diff) * report(action=define,hlabels=||"Method","Est. Variance"||) report(row=new,atcol=1) "BHHH" bhhhvar report(row=new,atcol=1) "BFGS" bfgsvar report(row=new,atcol=1) "Info" infovar report(row=new,atcol=1) "Sample Info" ainfovar report(action=show)