/* The following code replicates the code shown in Table A1 of the appendix of the article: "A Simple and Efficient Method of Estimating the Magnitude and Precision of Welfare Changes" by Jon A. Breslaw and J. Barry Smith It should work with all versions of GAUSS */ @ ================================================================ @ @ Purpose: Evaluates the CV and its standard error for a @ @ given price change using the B&S method @ @ ================================================================ @ @ -------------- McKenzie-Pearce Example --------------------------@ clear p, y, x; @ clear globals @ let p0 = 1.0 2.0; @ initial price vector @ let p1 = 1.1 1.6923; @ final price vector @ y0 = 220; @ income @ num = 20; @ number of steps @ let b = 1 1; @ parameters in demand function @ let omega[2,2] = .10 -.05 @ variance covariance matrix of @ -.05 .05; @ estimated coefficients @ call ecv; @ evaluate compensating variation @ end; proc q(x,b); @ demand function @ local pa, pb, y, za, zb; pa = x[1]; pb = x[2]; y = x[3]; za = b[1]*pb*y/(pa*(b[2]*pa+b[1]*pb)); zb = b[2]*pa*y/(pb*(b[2]*pa+b[1]*pb)); retp(za|zb); endp; @==================================================================@ proc 0= ecv; @ eval compensating variation @ local del, tcv, h, g, gf, vh, vy, lam, i, cv,dwl, dhdp, ss, covy, np, ny, nb; clear tcv,vy; del = (p1-p0)/num; @ step size @ p = p0; y = y0; @ initial price & income @ np = rows(p); nb = rows(b); @ number of prices & parameters@ i = 1; do until i > num; @ loop through the steps @ x = p|y; @ variables in demand function @ h = q(x,b); @ Hicks = Marshallian demand @ g = gradp(&qx,x); @ gradient wrt variables @ gf = gradp(&qb,b); @ gradient wrt parameters @ dhdp = g[.,1:np]+g[.,np+1]*h'; @ Slutsky @ cv = del'h + .5*del'dhdp*del; @ Taylor expansion @ ss = gf*omega*gf'; @ Rao expansion for Var(h) @ lam = del'g[.,np+1]; if (p == p0); vy = del'ss*del; @ Var(C) for first step @ covy = zeros(nb,1); else; vy = vy.*(1+lam)^2 @ Var(C) remaining steps @ + del'ss*del.*(3+2*lam) + 2*(1+lam)*del'gf*covy; covy = covy + omega*gf'del; endif; tcv = tcv + cv; @ aggregate CV @ p = p + del; @ augment price by step @ y = y + cv; @ augment y by CV @ i = i + 1; endo; @ augment counter @ dwl = tcv - (p1-p0)'q(p1|y,b); @ dead weight loss @ "TCV = " tcv; "DWL = " dwl; @ print out results @ "stder TCV = " sqrt(vy); endp; proc qx(x); retp(q(x,b)); endp; proc qb(b); retp(q(x,b)); endp; @==================================================================@