* * Example 18.7 from pp 530-531 * open data tablefd-1[1].txt data(format=prn,org=columns) 1 20 id y e * set ysq = y**2 set logy = log(y) set recy = 1/y * nonlin p lambda * frml yfrml = y-p/lambda frml ysqfrml = y**2-p*(p+1)/lambda**2 frml recyfrml = 1/y-lambda/(p-1) frml logyfrml = log(y)-%digamma(p)+log(lambda) * compute p=2,lambda=1.0 * * Maximum likelihood * frml loglike = p*log(lambda)-%lngamma(p)-lambda*y+(p-1)*log(y) maximize(method=bhhh) loglike * instruments constant * * The RATS NLSYSTEM instruction handles the weight matrix a bit differently than * the description on page 539: it computes a new one after each iteration of the * non-linear optimization. The following two operation will produce the same * results as the process described in the text: * * Step 1: Computes the minimum distance estimator using the identity matrix * as the sigma matrix of the residuals. * Step 2: Use NLSYSTEM with the "SECONDSTEP" option. This computes a single * weight matrix at the initial parameter values. * * Note that the standard errors computed in the text aren't correct. You can't do * the simple calculation using a different weight matrix than was used in * estimating the coefficients. * nlsystem(instruments,nosigma,cv=%identity(4)) / yfrml ysqfrml logyfrml recyfrml nlsystem(instruments,nosigma,zudep,secondstep) / yfrml ysqfrml logyfrml recyfrml