options crt; ? 9e6 ? ? coded for TSP 4.3 or higher ? by Clint Cummins rev. 11/21/1998 in klem; freq a; smpl 47,71; set t = @nob; title 'Generalized Leontief with symmetry - unrestricted (a)'; ? (for Translog, see below) dot k l e m; a. = q./qy; pp = p.; dot k l e m; r.. = sqrt(pp/p.); ? note: rkk = 1, rll = 1, etc. enddot; param dk. dl. de. dm.; enddot; frml eqk ak = dkk + dkl*rlk + dke*rek + dkm*rmk ; frml eql al = dkl*rkl + dll + dle*rel + dlm*rml ; frml eqe ae = dke*rke + dle*rle + dee + dem*rme ; frml eqm am = dkm*rkm + dlm*rlm + dem*rem + dmm ; const neq,4 nslope,6; lsq(maxit=50) eqk eql eqe eqm; ? (a) copy @logl lnl1; copy @covu sot; ? In Berndt's notation, this is S/T ? Optional extension: title 'compute an explicit Wald test for zero slopes'; dot dkl dke dkm dle dlm dem; frml z. .; enddot; analyz zdkl zdke zdkm zdle zdlm zdem; ? (a.2) title 'restricted model with zero slopes, but COVU=S/T (b)'; dot k l e m; frml eq.r a. = a.r; param a.r; enddot; lsq(wname=sot,maxitw=0) eqkr eqlr eqer eqmr; ? (b) copy @covu w1ot; mat wald = @tr - t*neq; ? lsq stores @tr = tr(T*S"W1) in Berndt's notation cdf(chisq,df=nslope) wald; print @wald wald; ? wald from analyz for comparison title 'restricted model with zero slopes, COVU unrestricted (c)'; lsq eqkr eqlr eqer eqmr; ? (c) copy @logl lnl0; copy @covu w0ot; mat lr = 2*(lnl1-lnl0); mat lr936 = t*(logdet(w0ot*t) - logdet(sot*t)) ; print lr,lr936; cdf(chisq,df=nslope) lr; title 'unrestricted model with zero slopes, but COVU=W0/T (d)'; lsq(wname=w0ot,maxitw=0) eqk eql eqe eqm; ? (d) mat lm = t*neq - @tr ; cdf(chisq,df=nslope) lm; ? summarize print wald lr lm; title 'Translog with symmetry - unrestricted (a)'; smpl 47,71; set t = @nob; tc = 0; dot k l e m; v. = p.*q.; tc = tc + v.; enddot; dot k l e; s. = v./tc; l.m = log(p./pm); param alpha.; enddot; ? With symmetry (9.65) frml eqk sk = alphak + gkk*lkm + gkl*llm + gke*lem; frml eql sl = alphal + gkl*lkm + gll*llm + gle*lem; frml eqe se = alphae + gke*lkm + gle*llm + gee*lem; param gkk gkl gke gll gle gee; const neq,3 nslope,6; lsq eqk eql eqe; ? (a) copy @logl lnl1; copy @covu sot; title '2 ways to compute Wald test (b)'; ? optional extension -- direct Wald test dot gkk gkl gke gll gle gee; frml z. .; enddot; analyz zgkk zgkl zgke zgll zgle zgee; ? (a.2) dot k l e; frml eq.r s. = s.r; ? restricted model with zero slopes param s.r; enddot; lsq(wname=sot,maxitw=0) eqkr eqlr eqer; ? (b) copy @covu w1ot; mat wald = @tr - t*neq; cdf(chisq,df=nslope) wald; print @wald,wald; title '2 ways to compute Likelihood Ratio test (c)'; lsq eqkr eqlr eqer; ? (c) copy @logl lnl0; copy @covu w0ot; mat lr = 2*(lnl1-lnl0); mat lr936 = t*(logdet(w0ot*t) - logdet(sot*t)) ; print lr,lr936; cdf(chisq,df=nslope) lr; title 'Lagrange Multiplier test (d)'; lsq(wname=w0ot,maxitw=0) eqk eql eqe; ? (d) mat lm = t*neq - @tr ; cdf(chisq,df=nslope) lm; ? summarize print wald lr lm;