** STATA Sample Nonlinear models Program by Colin Cameron ** Does logit, probit, multinomial logit, ordered logit, poisson, tobit ** Program stmlogit.do October 1999 * To run this program you need files * jaggia.asc and * in your directory * This Stata program demonstrates * binary logit, probit and OLS * multinomial logit and ordered logit * poisson * tobit * For more explanation on basic Stata see stjaggia.do ********** DATA DESCRIPTION * * The original data are from Sanjiv Jaggia and Satish Thosar, 1993, * "Multiple Bids as a Consequence of Target Management Resistance" * Review of Quantitative Finance and Accounting, 447-457. * This is used e.g. in A.C.Cameron and P.K.Trivedi (1998) * "Regression Analysis of Count Data", Cambridge University Press, pp.146-151. * * 1. DOCNO Doc No. * 2. WEEKS Weeks * 3. NUMBIDS Count (Dependent Variable) * 4. TAKEOVER Delta (1 if taken over) * 5. BIDPREM Bid Premium * 6. INSTHOLD Institutional Holdings * 7. SIZE Size measured in billions * 8. LEGLREST Legal Restructuring * 9. REALREST Real Restructuring * 10. FINREST Financial Restructuring * 11. REGULATN Regulation * 12. WHTKNGHT White Knight * and this program will create * 13. SIZESQ Size Squared ********** CLOSE FILES POSSIBLY OPEN FROM PREVIOUS EXECUTION clear capture log close * capture in front means program continues even if no log file open ********** CREATE OUTPUT FILE log using stmlogit.log, replace di "stmlogit.do by Colin Cameron: Stata logit example" ********** ADJUSTMENTS FOR LARGER SIZE PROBLEMS set maxvar 100 width 1000 set matsize 100 ********** READ DATA * You need file jaggia.asc in your directory * Infile: FREE FORMAT WITHOUT DICTIONARY * As there is space between each observation data is also space-delimited * free format and then there is no need for a dictionary file * The following command spans more that one line so use /* and */ infile docno weeks numbids takeover bidprem insthold size leglrest /* */ realrest finrest regulatn whtknght using jaggia.asc ********** DATA TRANSFORMATIONS gen sizesq = size*size label variable sizesq "size squared" * Code numbids data as 1 or 0 for binary logit gen dbids=numbids>0 /* equals 1 if numbids>0 and 0 otherwise */ * Code numbids data as 1, 2 or 3 for Stata mlogit * Here y=1 will be numbids=0 * y=2 will be numbids=1 * y=3 will be numbids=2 or more gen ybids = numbids + 1 replace ybids = 3 if ybids>3 /* use replace here as modifying existing variable */ ******** CHECK DATA: DESCRIPTIVE STATISTICS describe summarize * Full regressor set is * regress dbids leglrest realrest finrest whtknght /* * */ bidprem insthold size sizesq regulatn * where use /* and */ as command spans two lines * Here have only BIDPREM as regressor for simplicity ****************** REGRESSIONS FOR 0, 1 DATA ******************* *** OLS REGRESSION regress dbids bidprem * Same regression with robust standard errors regress dbids bidprem, robust predict pols *** PROBIT REGRESSION probit dbids bidprem * Next reports dF/dx rather than betas dprobit dbids bidprem * Calculate predicted probability that y=1 for each person in the sample predict pprobit *** LOGIT REGRESSION logit dbids bidprem * Calculate predicted probability that y=1 for each person in the sample predict plogit *** COMPARE PREDICTED PROBABILITIES ACROSS MODELS summarize dbids pols pprobit plogit ****************** REGRESSIONS FOR 0, 1, 2 DATA **************** *** MULTINOMIAL LOGIT REGRESSION mlogit ybids bidprem, base(1) * Calculate predicted probability that y=1, 2 or 3 for each person in the sample predict p1mlogit p2mlogit p3mlogit summarize ybids dbids p1mlogit p2mlogit p3mlogit *** ORDERED LOGIT REGRESSION ologit ybids bidprem, table * Calculate predicted probability that y=1, 2 or 3 for each person in the sample predict p1ologit p2ologit p3ologit summarize ybids dbids p1ologit p2ologit p3ologit ****************** REGRESSIONS FOR 0,1,2,... DATA ************** *** OLS REGRESSION for NUMBIDS regress numbids bidprem, robust *** POISSON REGRESSION for NUMBIDS poisson numbids bidprem, robust *** TOBIT REGRESSION for NUMBIDS tobit numbids bidprem, ll(0) ********** CLOSE OUTPUT log close