* A Poisson Model for Count Data * Reference: W.H. Greene, Econometric Analysis. * Second Edition - Section 21.8, pp. 676-8 * Third Edition - Section 19.9, pp. 931-4 * Fourth Edition - Section 19.9, pp. 880-2 * SAMPLE 1 20 * Data on ship accidents (TABLE 21.12 - Second Edition) * * Ship Type Year constructed Amount of * 60-4 65-9 70-4 75-9 Service Accidents * ------------- ------------------- READ OBS A B C D E YR60 YR65 YR70 YR75 SERV ACTUAL 1 1 0 0 0 0 1 0 0 0 127 0 2 1 0 0 0 0 0 1 0 0 63 4 3 1 0 0 0 0 0 0 1 0 1095 18 4 1 0 0 0 0 0 0 0 1 2244 11 5 0 1 0 0 0 1 0 0 0 17176 29 6 0 1 0 0 0 0 1 0 0 20370 53 7 0 1 0 0 0 0 0 1 0 13099 44 8 0 1 0 0 0 0 0 0 1 7117 18 9 0 0 1 0 0 1 0 0 0 1179 1 10 0 0 1 0 0 0 1 0 0 676 1 11 0 0 1 0 0 0 0 1 0 1948 2 12 0 0 1 0 0 0 0 0 1 274 1 13 0 0 0 1 0 1 0 0 0 251 0 14 0 0 0 1 0 0 1 0 0 288 0 15 0 0 0 1 0 0 0 1 0 1208 11 16 0 0 0 1 0 0 0 0 1 2051 4 17 0 0 0 0 1 1 0 0 0 45 0 18 0 0 0 0 1 0 1 0 0 789 7 19 0 0 0 0 1 0 0 1 0 2161 12 20 0 0 0 0 1 0 0 0 1 542 1 * Poisson Regression with the NL command. * The LGAM(x) function with the GENR command generates a log gamma function. GENR FACTORY = LGAM(ACTUAL+1) * * Estimation of a Poisson regression model by maximum likelihood * (The Unrestricted model) XB: B0+B1*B+B2*C+B3*D+B4*E+B5*YR65+B6*YR70+B7*YR75+B8*SERV NL 1 / NCOEF=9 LOGDEN GENRVAR EQ -EXP([XB])+ & ACTUAL*([XB]) - & FACTORY COEF B0 1 B1 0 B2 0 B3 0 B4 0 B5 0 B6 0 B7 0 B8 0 END * Save the value of the log-likelihood function GEN1 LLFUN=$LLF GENR DEV=0 IF(ACTUAL.GT.0) DEV=2*ACTUAL*LOG(ACTUAL/EXP([XB])) ?STAT DEV / SUM=GSQUARE PRINT GSQUARE DELETE B0-B8 * * Impose the restriction that the year of construction is not important. * (The Restricted model) XB: B0+B1*B+B2*C+B3*D+B4*E+B8*SERV NL 1 / NCOEF=6 LOGDEN GENRVAR EQ -EXP([XB])+ & ACTUAL*([XB]) - & FACTORY COEF B0 1 B1 0 B2 0 B3 0 B4 0 B8 0 END GEN1 LLFREST=$LLF * * Compute the likelihood ratio test statistic - if this exceeds the * critical value from a chi-square distribution with 3 degrees of * freedom then there is evidence to reject the hypothesis that * year of construction is not important. * GEN1 LRSTAT=2*(LLFUN-LLFREST) PRINT LRSTAT GENR DEV=0 IF(ACTUAL.GT.0) DEV=2*ACTUAL*LOG(ACTUAL/EXP([XB])) ?STAT DEV / SUM=GSQUARE PRINT GSQUARE STOP