/* ** Lesson 7.2: Box-Cox Transformation ** U. S. Money Demand Equation ** Greene [1999], Chapter 10 */ use gpe2; output file=gpe\output7.2 reset; load x[21,4]=gpe\money.txt; @ scale and re-arrange data: m,r,y @ x=(x[2:21,3]/1000)~(x[2:21,2])~(x[2:21,4]/1000); call reset; _method=0; _iter=200; _step=1; _conv=1; _jacob=&jf; @ starting linear model @ b=x[.,1]/(ones(rows(x),1)~x[.,2:3]); _b=b|1.0|1.0; /* @ starting log model @ b=ln(x[.,1])/(ones(rows(x),1)~ln(x[.,2:3])); _b=b|-0.01|0.01; */ _nlopt=1; @ MAXLIK @ call estimate(&rf,x); end; proc jf(data,b); @ jacobian @ local k; k=rows(b); @ the last parameter @ retp(data[.,1]^(b[k]-1)); endp; proc rf(data,b); @ residual: general model @ local r,m,y,e; @ box-cox transformation @ m=(data[.,1]^b[5]-1)/b[5]; r=(data[.,2]^b[4]-1)/b[4]; y=(data[.,3]^b[4]-1)/b[4]; e=m-b[1]-b[2]*r-b[3]*y; retp(e); endp;