options crt; name fisher 'Paasche, Laspeyres, and Fisher indices'; ? ? (using TSP 4.1-compatible matrix commands) ? TSP 4.2B (April 1994) ? Author: Clint Cummins (revised 9.95 by BHH) ? list plist pe pj ptyw19 pjrc ; ? insert your variable names here list qlist qe qj qtyw19 qjrc ; list pqlist pe qe pj qj ptyw19 ptyw19 pjrc qjrc ; set T = 20; smpl 1,T; ? Set the number of observations T. ? Change for your FREQ and SMPL. ? Generate some test data (growth at 5 percent plus some noise). supres smpl ; random(seedin=39318); dot plist qlist; smpl 1 1 ; . = 1 ; smpl 2 t ; random (uniform) e ; . = .(-1)*(1.05) + .1*e ; enddot; smpl 1 t ; set TM1 = T-1; smpl 1,TM1; mmake plag plist; ? Make matrices with the first T-1 obs. mmake qlag qlist; smpl 2,T; mmake p plist; ? Make matrices with the last T-1 obs. mmake q qlist; ? length qlist nser; ? Number of series. mform(nrow=nser,ncol=1) ones=1; ? Create a vector of ones. ? pqd p q pq; pqd p qlag pql; pqd plag q plq; pqd plag qlag plql; ? ? Paasche is current prices over lagged prices, using lagged quantities ? as weights. ? paasche = pql/plql; normal paasche 2 1; qp = pq/paasche; ? ? Laspeyre is current prices over lagged prices, using current quantities ? as weights. ? laspeyre = pq/plq; normal laspeyre 2 1; ql = pq/laspeyre; ? ? Fisher ideal index is the geometric mean of the two. ? fisher = sqrt(paasche*laspeyre); normal fisher 2 1; qf = pq/fisher; ? print paasche laspeyre fisher ; print qp qp qf; ? ? For chained versions, use dynamic GENRs (and renormalize, if ? necessary) ? pach = paasche; lach = laspeyre; fich = fisher; smpl 3,T; pach = pach(-1)*paasche; lach = lach(-1)*laspeyre; fich = fich(-1)*fisher; smpl 2,T; print paasche pach ; print laspeyre lach ; print fisher fich; ? ? ======================================================================= ? proc pqd pi qi piqisum ; ? ? Procedure to compute the sum of the ps and qs for each obs (this ? version for TSP 4.2 or 4.3). ? mat sum = (pi%qi)*ones ; unmake sum piqisum ; endproc pqd ; ? ======================================================================= ? proc pqd41 pi qi piqisum ; ? ? Procedure to compute the sum of the ps and qs for each obs (this ? version for TSP 4.1, using old matrix commands). ? memult pi qi piqi ; mmult piqi ones sum ; unmake sum piqisum ; endproc pqd41 ; ? ======================================================================