* * Example from section 15.7, page 600 * Grouped logit and probit * all 10 open data table15-4.prn * * We use "own" rather than "n" for the number owning a home because RATS doesn't * take case into account in processing variable names, that is, "n" and "N" can't * be used if you want different series. * data(format=prn,org=columns) / x N own * * Generate phat, the logit function and the variance series for the * heteroscedasticity correction. * set phat = own/N set logit = log(phat/(1-phat)) set v = 1.0/(phat*(1-phat)*n) * * Estimate the grouped logit model. Note that the coefficients are slightly * different because the variables are computed to full precision here, while in * table 15.5, the x=20 phat is truncated to 2 decimal places. * linreg(spread=v) logit # constant x * * PRJ(DISTRIB=LOGIT) computes statistics based upon the fitted values using the * logistic distribution. PHAT will be the predicted probabilities and DP will be * the density function. If we multiply DP by %BETA(2), we'll get the sensitivity * of the probability to changes in the "X" variable. * prj(distrib=logit,cdf=phat,density=dp) set dp = dp*%beta(2) scatter(hlabel="X, Income, thousands of dollars",vlabel="Change in probability") # x dp * * Grouped probit. We recompute the data phat's because we used the same name for * the predicted probabilities. Again, the output will be slightly different * because of rounding. * set phat = own/N set index = %invnormal(phat) * linreg index # constant x * * Compute, print and graph the predicting probabilities * prj(cdf=phat) ihat print / x ihat phat scatter # x phat * * For completeness, do the regression with 5 added to the index * set probit = 5+index linreg probit # constant x