* W.H. Greene, Econometric Analysis, Fourth Edition, 2000. SAMPLE 1 601 READ (FAIR_PT.shd) / NAMES * Example 20.12, p. 920. * Obtain frequencies, p. 920 STAT y / PFREQ * Obtain the sample means, p. 920. STAT / ALL * Model Estimates presented in Table 20.4, p. 921. * Column (1) OLS y z2 z3 z5 z7 z8 * For TOBIT the "normalized coefficients" on the SHAZAM output * are the estimates reported in Column (4) of Table 20.4 TOBIT y z2 z3 z5 z7 z8 / COEF=ALPHA INDEX=XALPHA * Estimate the "regression coefficients" as reported in Column (2) * of Table 20.4. * TEST commands can be used to calculate the coefficients and * standard errors reported on the SHAZAM output as * TEST VALUE and STD. ERROR OF TEST VALUE, respectively. TEST CONSTANT/y TEST z2/y * Allocate space for storing results. DIM BETA 5 BETA_SE 5 * The coefficient and standard error calculated with the TEST command * are saved in the temporary variables $VAL and $STES, respectively. GEN1 BETA:1=$VAL GEN1 BETA_SE:1=$STES * To calculate and save the rest of the coefficients and standard * errors the estimation command must be repeated. * The ? prefix suppresses output. ?TOBIT y z2 z3 z5 z7 z8 TEST z3/y GEN1 BETA:2=$VAL GEN1 BETA_SE:2=$STES ?TOBIT y z2 z3 z5 z7 z8 TEST z5/y GEN1 BETA:3=$VAL GEN1 BETA_SE:3=$STES ?TOBIT y z2 z3 z5 z7 z8 TEST z7/y GEN1 BETA:4=$VAL GEN1 BETA_SE:4=$STES ?TOBIT y z2 z3 z5 z7 z8 TEST z8/y GEN1 BETA:5=$VAL GEN1 BETA_SE:5=$STES * The value of the log-likelihood function is saved in the * temporary variable $LLF. GEN1 LT=$LLF GEN1 NCOEF=$K GEN1 SIG2=$SIG2 GEN1 SIG=SQRT(SIG2) * Estimate marginal effects as reported in Column (3) of Table 20.4. * Calculate the scale factor using the formula on p. 921. STAT XALPHA / MEAN=mu DISTRIB mu / TYPE=NORMAL GEN1 scale=$CDF GEN1 K=NCOEF-2 SAMPLE 1 K GENR SLOPE=BETA*scale GENR SLOPE_SE=BETA_SE*scale * Print results for Columns (2) and (3) of Table 20.4. FORMAT(5A4) READ VARIABLE / FORMAT BYVAR Z2 Z3 Z5 Z7 Z8 NAMEFMT(1X,A8,1X,2(2X,A8)/10X,2(2X,A8)) FORMAT(1X,A8,2F10.3/10X,2(2X,'(',F6.3,')')) PRINT VARIABLE BETA SLOPE BETA_SE SLOPE_SE / FORMAT * Textbook typo: In Table 20.4, Column (3), the standard error reported * as (0.184) should be (0.0184). * Calculate the Chesher-Irish test of normality, pp. 916-917. SAMPLE 1 601 GENR XBETA=XALPHA*SIG * The ? prefix suppresses output. ?DISTRIB XALPHA / TYPE=NORMAL CDF=CDFZ PDF=FZ GENR h=FZ/(1-CDFZ) * Generate a 0-1 dummy variable GENR z=DUM(y) * Calculate the generalized residuals, p. 917. GENR EGEN=(z*(Y-XBETA)-(1-z)*SIG*h)/(SIG2) * The sum of the residuals must be zero. STAT EGEN GENR ONE=1 GENR ez2=EGEN*z2 GENR ez3=EGEN*z3 GENR ez5=EGEN*z5 GENR ez7=EGEN*z7 GENR ez8=EGEN*z8 GENR b=(z*(((Y-XBETA)**2/SIG2)-1) + (1-z)*XALPHA*h) / (2*SIG2) GENR EGEN3=EGEN**3 GENR EGEN4=EGEN**4-3*EGEN*EGEN * Auxiliary regression ?OLS ONE ez2 ez3 ez5 ez7 ez8 EGEN b EGEN3 EGEN4 / NOCONSTANT * Test statistic for the Chesher-Irish normality test and p-value, p. 922. GEN1 LM=$N*$RAW DISTRIB LM / TYPE=CHI DF=2 GEN1 pvalue=1-$CDF PRINT LM pvalue * Verify the calculation of the test statistic with a matrix calculation. COPY ez2 ez3 ez5 ez7 ez8 EGEN b EGEN3 EGEN4 A MATRIX LM=ONE'*A*INV(A'A)*A'*ONE PRINT LM * Column (5) PROBIT z z2 z3 z5 z7 z8 GEN1 LP=$LLF * Column (6) - Truncated regression with the non-limit observations SET NOWARNSKIP SKIPIF (y.LE.0.01) DIM BTOLS 7 * OLS estimation gives biased estimates (see pp. 902-903) OLS y z2 z3 z5 z7 z8 / COEF=BTOLS GEN1 BTOLS:7=0.15 * Specify the log-likelihood function as described in * Example 20.6, p. 904. Typo -- in the expression for logL, * log(2 pi) should be -log(2 pi). GAMMAX: (B2*z2+B3*z3+B5*z5+B7*z7+B8*z8+B0)*THETA GENR CONST=-LOG(2*$PI)/2 * Maximum likelihood estimation NL / NCOEF=7 LOGDEN START=BTOLS EQ -(([GAMMAX]-THETA*y)**2)/2-LOG(NCDF([GAMMAX]))+CONST+LOG(THETA) END * Recover an estimate of sigma. With the TEST command this is * reported as TEST VALUE. TEST 1/THETA GEN1 LTR=$LLF * The value of the log-likelihood reported for Truncated Regression * in Table 20.4, p. 921 should be -392.71. DELETE SKIP$ * Cragg/Greene specification test, pp. 915 and 922. GEN1 LR=-2*(LT-(LP+LTR)) DISTRIB LR / TYPE=CHI DF=7 GEN1 pvalue=1-$CDF PRINT LR pvalue STOP