? Estimator for a Geometric Lag Model ? Assumes dependent variable is Y and one independent variable, ? named X. ? First define matrices to keep parameters and sums of squares ? MATRIX ; EE = INIT(19,1,0) ; L = INIT(19,1,0) $ ? ? Set up initial value of the subscript and estimation criterion ? CALC ; i = 1 ; eemin = 9999999 ; best = 0 $ ? ? Now define the procedure to estimate the regression and keep the results. We also retain the ? optimal value of lambda by using two indirect CALC commands in MATRIX. ? PROCEDURE SAMPLE ; 1 $ CREATE ; z = lambda ; xstar = x $ SAMPLE ; 2 - ... the end of the sample $ CREATE ; z=lambda*z[-1] ; xstar=x+lambda*xstar[-1] $ SAMPLE ; 1 - ... the end of the sample $ REGRESS ; Lhs = y ; Rhs = One,z,xstar $ MATRIX ; EE(i) = sumsqdev ; L(i) = lambda ; if [ sumsqdev < eemin] best = lambda ; eemin = sumsqdev $ CALC ; i = i + 1 $ ENDPROC ? ? Execute the procedure ? EXECUTE ; lambda = .05, .95, .05 $ MPLOT ; Lhs=L ; Rhs=EE ; Fill ; endpoints=0,1 $ SAMPLE ; 1 $ CREATE ; delta = 0 $ SAMPLE ; 2 $ CREATE ; delta = x $ SAMPLE ; 3 - ... end of sample $ CREATE ; delta = xstar[-1] + lambda * delta[-1] $ SAMPLE ; 1 - ... end of sample $ CREATE ; t=trn(1,1) ; d=b(2)*delta + t * b(3) * lambda^(t-1) $ To get the covariance matrix, the one matrix command, MATRIX ; Var = ssqrd * XPXI (one,xstar,z,d) $ is sufficient. The statistical results could be displayed with MATRIX ; est = b / lambda ; STAT (est,var) $  of sample $ CREATE ; delta = xstar[-1] + lambda * delta[-1] $ SAMPLE ; 1 - ... end of sample $ CREATE ; t=trn(1,1) ; d=b(2)*delta + t * b(3) * lambda^(t-1) $ To get the covariance matrix, the one matrix command, MATRIX ; Var = ssqrd * XPXI (one,xstar,z,d) $ is sufficient. The statistical results could be displayed with MATRIX ; Stat (EST,VAR) $