---------------------------------------------------------------------------------------------------------------- log: C:\Documents and Settings\jlee\My Documents\EC671\tobit_cnreg_intreg.log log type: text opened on: 7 Nov 2004, 14:03:16 . . ** Tobit Models . . use http://www.stata-press.com/data/r8/auto, clear (1978 Automobile Data) . . generate wgt = weight/1000 . regress mpg wgt Source | SS df MS Number of obs = 74 -------------+------------------------------ F( 1, 72) = 134.62 Model | 1591.99024 1 1591.99024 Prob > F = 0.0000 Residual | 851.469221 72 11.8259614 R-squared = 0.6515 -------------+------------------------------ Adj R-squared = 0.6467 Total | 2443.45946 73 33.4720474 Root MSE = 3.4389 ------------------------------------------------------------------------------ mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- wgt | -6.008687 .5178782 -11.60 0.000 -7.041058 -4.976316 _cons | 39.44028 1.614003 24.44 0.000 36.22283 42.65774 ------------------------------------------------------------------------------ . . replace mpg = 17 if mpg <= 17 (14 real changes made) . * this replacement is not needed, though. . . tobit mpg wgt, ll nolog Tobit estimates Number of obs = 74 LR chi2(1) = 72.85 Prob > chi2 = 0.0000 Log likelihood = -164.25438 Pseudo R2 = 0.1815 ------------------------------------------------------------------------------ mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- wgt | -6.87305 .7002559 -9.82 0.000 -8.268658 -5.477442 _cons | 41.49856 2.05838 20.16 0.000 37.39621 45.6009 -------------+---------------------------------------------------------------- _se | 3.845701 .3663309 (Ancillary parameter) ------------------------------------------------------------------------------ Obs. summary: 18 left-censored observations at mpg<=17 56 uncensored observations . * ll (lower limit), ul (upper limit) . tobit mpg wgt, ul(24) nolog Tobit estimates Number of obs = 74 LR chi2(1) = 75.59 Prob > chi2 = 0.0000 Log likelihood = -126.95737 Pseudo R2 = 0.2294 ------------------------------------------------------------------------------ mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- wgt | -3.907593 .3843458 -10.17 0.000 -4.673593 -3.141593 _cons | 32.87375 1.258339 26.12 0.000 30.36588 35.38161 -------------+---------------------------------------------------------------- _se | 2.166353 .2266904 (Ancillary parameter) ------------------------------------------------------------------------------ Obs. summary: 51 uncensored observations 23 right-censored observations at mpg>=24 . * ul (upper limit 24 is imposed) . . tobit mpg wgt, ll (17) ul(24) nolog Tobit estimates Number of obs = 74 LR chi2(1) = 77.60 Prob > chi2 = 0.0000 Log likelihood = -104.25976 Pseudo R2 = 0.2712 ------------------------------------------------------------------------------ mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- wgt | -5.764448 .7245417 -7.96 0.000 -7.208457 -4.320438 _cons | 38.07469 2.255917 16.88 0.000 33.57865 42.57072 -------------+---------------------------------------------------------------- _se | 2.886337 .3952143 (Ancillary parameter) ------------------------------------------------------------------------------ Obs. summary: 18 left-censored observations at mpg<=17 33 uncensored observations 23 right-censored observations at mpg>=24 . . ** Tobit Models and marginal effects . . use http://fmwww.bc.edu/ec-p/data/wooldridge/MROZ, clear . . regress hours nwifeinc educ exper expersq age kidslt6 kidsge6 Source | SS df MS Number of obs = 753 -------------+------------------------------ F( 7, 745) = 38.50 Model | 151647606 7 21663943.7 Prob > F = 0.0000 Residual | 419262118 745 562767.944 R-squared = 0.2656 -------------+------------------------------ Adj R-squared = 0.2587 Total | 570909724 752 759188.463 Root MSE = 750.18 ------------------------------------------------------------------------------ hours | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- nwifeinc | -3.446636 2.544 -1.35 0.176 -8.440898 1.547626 educ | 28.76112 12.95459 2.22 0.027 3.329284 54.19297 exper | 65.67251 9.962983 6.59 0.000 46.11365 85.23138 expersq | -.7004939 .3245501 -2.16 0.031 -1.337635 -.0633524 age | -30.51163 4.363868 -6.99 0.000 -39.07858 -21.94469 kidslt6 | -442.0899 58.8466 -7.51 0.000 -557.6148 -326.565 kidsge6 | -32.77923 23.17622 -1.41 0.158 -78.2777 12.71924 _cons | 1330.482 270.7846 4.91 0.000 798.8906 1862.074 ------------------------------------------------------------------------------ . . tobit hours nwifeinc educ exper expersq age kidslt6 kidsge6, ll(0) nolog Tobit estimates Number of obs = 753 LR chi2(7) = 271.59 Prob > chi2 = 0.0000 Log likelihood = -3819.0946 Pseudo R2 = 0.0343 ------------------------------------------------------------------------------ hours | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- nwifeinc | -8.814243 4.459096 -1.98 0.048 -17.56811 -.0603725 educ | 80.64561 21.58322 3.74 0.000 38.27453 123.0167 exper | 131.5643 17.27938 7.61 0.000 97.64231 165.4863 expersq | -1.864158 .5376615 -3.47 0.001 -2.919667 -.8086479 age | -54.40501 7.418496 -7.33 0.000 -68.96862 -39.8414 kidslt6 | -894.0217 111.8779 -7.99 0.000 -1113.655 -674.3887 kidsge6 | -16.218 38.64136 -0.42 0.675 -92.07675 59.64075 _cons | 965.3053 446.4358 2.16 0.031 88.88531 1841.725 -------------+---------------------------------------------------------------- _se | 1122.022 41.57903 (Ancillary parameter) ------------------------------------------------------------------------------ Obs. summary: 325 left-censored observations at hours<=0 428 uncensored observations . . * -- fixup for expersq : take square of mean rather than mean of square per JMW . summ exper,meanonly . local exp2=r(mean)^2 . mfx compute, at(mean expersq=`exp2') predict(ystar(0,.)) Marginal effects after tobit y = E(hours*|hours>0) (predict, ystar(0,.)) = 687.31745 ------------------------------------------------------------------------------ variable | dy/dx Std. Err. z P>|z| [ 95% C.I. ] X ---------+-------------------------------------------------------------------- nwifeinc | -5.687381 2.87788 -1.98 0.048 -11.3279 -.046836 20.129 educ | 52.03649 13.82 3.77 0.000 24.9495 79.1234 12.2869 exper | 84.89173 12.398 6.85 0.000 60.593 109.19 10.6308 expersq | -1.202846 .36661 -3.28 0.001 -1.92139 -.484297 113.014 age | -35.10478 4.66947 -7.52 0.000 -44.2568 -25.9528 42.5378 kidslt6 | -576.8666 70.93 -8.13 0.000 -715.887 -437.847 .237716 kidsge6 | -10.46465 24.94 -0.42 0.675 -59.3456 38.4163 1.35325 ------------------------------------------------------------------------------ . . * -- marginal effects conditional on positive hours . mfx compute, at(mean expersq=`exp2') predict(e(0,.)) Marginal effects after tobit y = E(hours|hours>0) (predict, e(0,.)) = 1065.1973 ------------------------------------------------------------------------------ variable | dy/dx Std. Err. z P>|z| [ 95% C.I. ] X ---------+-------------------------------------------------------------------- nwifeinc | -3.987413 2.01764 -1.98 0.048 -7.94192 -.032909 20.129 educ | 36.48269 9.68927 3.77 0.000 17.4921 55.4733 12.2869 exper | 59.51744 8.68378 6.85 0.000 42.4975 76.5373 10.6308 expersq | -.843313 .25692 -3.28 0.001 -1.34686 -.339765 113.014 age | -24.6119 3.27362 -7.52 0.000 -31.0281 -18.1957 42.5378 kidslt6 | -404.4402 49.722 -8.13 0.000 -501.893 -306.987 .237716 kidsge6 | -7.336744 17.485 -0.42 0.675 -41.607 26.9335 1.35325 ------------------------------------------------------------------------------ . * e(a,b) gives the conditioanl expectation given a < Xb < b. . . . *** Panel RE Tobit (xttobit) . . use http://www.stata-press.com/data/r8/nlswork, clear (National Longitudinal Survey. Young Women 14-26 years of age in 1968) . xttobit ln_wage union age grade not_smsa south occ_code, i(id) ul(1.9) tobit nolog Random-effects tobit regression Number of obs = 19151 Group variable (i): idcode Number of groups = 4140 Random effects u_i ~ Gaussian Obs per group: min = 1 avg = 4.6 max = 12 Wald chi2(6) = 3303.29 Log likelihood = -6672.7585 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ ln_wage | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- union | .1545505 .0069135 22.35 0.000 .1410002 .1681008 age | .0099367 .000414 24.00 0.000 .0091252 .0107482 grade | .0788248 .0022308 35.33 0.000 .0744525 .0831972 not_smsa | -.1276947 .0088914 -14.36 0.000 -.1451215 -.1102679 south | -.0868263 .0086892 -9.99 0.000 -.1038569 -.0697957 occ_code | -.0190243 .0010974 -17.34 0.000 -.0211751 -.0168735 _cons | .521857 .0320114 16.30 0.000 .4591158 .5845982 -------------+---------------------------------------------------------------- /sigma_u | .2847095 .0044262 64.32 0.000 .2760343 .2933848 /sigma_e | .2497528 .0018149 137.61 0.000 .2461956 .25331 -------------+---------------------------------------------------------------- rho | .5651268 .0082516 .5489039 .5812407 ------------------------------------------------------------------------------ Likelihood-ratio test of sigma_u=0: chibar2(01)= 5920.66 Prob>=chibar2 = 0.000 Observation summary: 12288 uncensored observations 0 left-censored observations 6863 right-censored observations . *quadchk . . . ** Censored regression CNREG (each can be censored at a different point) . . use http://www.stata-press.com/data/r8/news, clear . . generate cnsrd = 0 . replace cnsrd = -1 if before82 (24 real changes made) . replace date = mdy(1,1,1982) if before82 (24 real changes made) . replace cnsrd = 1 if date>= . (11 real changes made) . replace date = mdy(1,1,1991) if date >= . (11 real changes made) . list date cnsrd in 1/12 +------------------+ | date cnsrd | |------------------| 1. | 8036 -1 | 2. | 8036 -1 | 3. | 8036 -1 | 4. | 8927.786 0 | 5. | 10466.89 0 | |------------------| 6. | 8823.7 0 | 7. | 9356.509 0 | 8. | 10784.71 0 | 9. | 10990.53 0 | 10. | 9033.669 0 | |------------------| 11. | 8036 -1 | 12. | 11290.81 0 | +------------------+ . . cnreg date lncltn famown, censored(cnsrd) nolog Censored normal regression Number of obs = 100 LR chi2(2) = 201.09 Prob > chi2 = 0.0000 Log likelihood = -519.74678 Pseudo R2 = 0.1621 ------------------------------------------------------------------------------ date | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- lncltn | -1377.138 76.92723 -17.90 0.000 -1529.797 -1224.478 famown | 576.8444 185.5287 3.11 0.002 208.6687 945.0201 _cons | 24439.46 815.7107 29.96 0.000 22820.71 26058.21 -------------+---------------------------------------------------------------- _se | 607.9846 53.19381 (Ancillary parameter) ------------------------------------------------------------------------------ Obs. summary: 24 left-censored observations 65 uncensored observations 11 right-censored observations . . ** Intreg (interval regression; even point data; needs depvar1 depvar2) . * point a a . * interval a b . * left censored . b . * right censored a . . . use http://www.stata-press.com/data/r8/womenwage, clear (Wages of women) . . tab wagecat Wage | category | ($1000s) | Freq. Percent Cum. ------------+----------------------------------- 5 | 14 2.87 2.87 10 | 83 17.01 19.88 15 | 158 32.38 52.25 20 | 107 21.93 74.18 25 | 57 11.68 85.86 30 | 30 6.15 92.01 40 | 19 3.89 95.90 50 | 14 2.87 98.77 51 | 6 1.23 100.00 ------------+----------------------------------- Total | 488 100.00 . by wagecat: keep if _n == 1 (479 observations deleted) . generate wage1 = wagecat[_n-1] (1 missing value generated) . keep wagecat wage1 . save lagwage, replace file lagwage.dta saved . . use http://www.stata-press.com/data/r8/womenwage, clear (Wages of women) . merge wagecat using lagwage . . generate wage2 = wagecat . replace wage2 = . if wagecat == 51 (6 real changes made, 6 to missing) . sort age, stable . list wage1 wage2 in 1/10 +---------------+ | wage1 wage2 | |---------------| 1. | . 5 | 2. | 5 10 | 3. | 5 10 | 4. | 10 15 | 5. | . 5 | |---------------| 6. | . 5 | 7. | . 5 | 8. | 5 10 | 9. | 5 10 | 10. | 5 10 | +---------------+ . . intreg wage1 wage2 age age2 nev_mar rural school tenure, nolog Interval regression Number of obs = 488 LR chi2(6) = 221.61 Log likelihood = -856.33293 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- age | .7914438 .4433604 1.79 0.074 -.0775265 1.660414 age2 | -.0132624 .0073028 -1.82 0.069 -.0275757 .0010509 nev_mar | -.2075022 .8119581 -0.26 0.798 -1.798911 1.383906 rural | -3.043044 .7757324 -3.92 0.000 -4.563452 -1.522637 school | 1.334721 .1357873 9.83 0.000 1.068583 1.600859 tenure | .8000664 .1045077 7.66 0.000 .5952351 1.004898 _cons | -12.70238 6.367117 -1.99 0.046 -25.1817 -.2230583 -------------+---------------------------------------------------------------- /lnsigma | 1.987823 .0346543 57.36 0.000 1.919902 2.055744 -------------+---------------------------------------------------------------- sigma | 7.299626 .2529634 6.82029 7.81265 ------------------------------------------------------------------------------ Observation summary: 0 uncensored observations 14 left-censored observations 6 right-censored observations 468 interval observations . . oprobit wage1 wage2 age age2 nev_mar rural school tenure, nolog Ordered probit estimates Number of obs = 468 LR chi2(7) = 1570.91 Prob > chi2 = 0.0000 Log likelihood = 0 Pseudo R2 = 1.0000 ------------------------------------------------------------------------------ wage1 | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- wage2 | 3.387503 515650.1 0.00 1.000 -1010652 1010659 age | .0079048 1656081 0.00 1.000 -3245858 3245858 age2 | -.0001439 27116.31 -0.00 1.000 -53147 53147 nev_mar | -.0011112 2911632 -0.00 1.000 -5706694 5706694 rural | -.0114906 2859866 -0.00 1.000 -5605235 5605235 school | .0022328 558215.5 0.00 1.000 -1094082 1094082 tenure | .000831 400255.5 0.00 1.000 -784486.4 784486.4 -------------+---------------------------------------------------------------- _cut1 | 42.45669 2.46e+07 (Ancillary parameters) _cut2 | 59.43884 2.54e+07 _cut3 | 76.37362 2.63e+07 _cut4 | 93.30152 2.77e+07 _cut5 | 110.3099 2.97e+07 _cut6 | 144.063 3.13e+07 ------------------------------------------------------------------------------ note: 468 observations completely determined. Standard errors questionable. . . . *** Panel RE INTREG (xtintreg) . . use http://www.stata-press.com/data/r8/nlswork3.dta, replace (National Longitudinal Survey. Young Women 14-26 years of age in 1968) . . xtintreg ln_wage1 ln_wage2 union age grade not_smsa south southXt occ_code, i(id) noskip intreg nolog Random-effects interval regression Number of obs = 19095 Group variable (i): idcode Number of groups = 4139 Random effects u_i ~ Gaussian Obs per group: min = 1 avg = 4.6 max = 12 LR chi2(7) = 3549.46 Log likelihood = -14856.934 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- union | .1409746 .0068364 20.62 0.000 .1275755 .1543737 age | .012631 .0005148 24.53 0.000 .0116219 .01364 grade | .0783789 .0020912 37.48 0.000 .0742802 .0824777 not_smsa | -.1333091 .0089209 -14.94 0.000 -.1507938 -.1158243 south | -.1218994 .0121087 -10.07 0.000 -.145632 -.0981669 southXt | .0021033 .0008314 2.53 0.011 .0004738 .0037328 occ_code | -.0185603 .001033 -17.97 0.000 -.020585 -.0165355 _cons | .4567546 .032493 14.06 0.000 .3930695 .5204398 -------------+---------------------------------------------------------------- /sigma_u | .282881 .0038227 74.00 0.000 .2753886 .2903734 /sigma_e | .2696119 .0015957 168.96 0.000 .2664843 .2727394 -------------+---------------------------------------------------------------- rho | .524003 .0075625 .5091676 .5388052 ------------------------------------------------------------------------------ Likelihood-ratio test of sigma_u=0: chibar2(01)= 6629.90 Prob>=chibar2 = 0.000 Observation summary: 14372 uncensored observations 157 left-censored observations 718 right-censored observations 3848 interval observations . *quadchk . . . *** Truncated Regression . . use http://www.stata-press.com/data/r8/laborsub, replace . . truncreg whrs kl6 k618 wa we, ll(0) nolog (note: 100 obs. truncated) Truncated regression Limit: lower = 0 Number of obs = 150 upper = +inf Wald chi2(4) = 10.05 Log likelihood = -1200.9157 Prob > chi2 = 0.0395 ------------------------------------------------------------------------------ whrs | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- eq1 | kl6 | -803.0042 321.3614 -2.50 0.012 -1432.861 -173.1474 k618 | -172.875 88.72898 -1.95 0.051 -346.7806 1.030579 wa | -8.821123 14.36848 -0.61 0.539 -36.98283 19.34059 we | 16.52873 46.50375 0.36 0.722 -74.61695 107.6744 _cons | 1586.26 912.355 1.74 0.082 -201.9234 3374.442 -------------+---------------------------------------------------------------- sigma | _cons | 983.7262 94.44303 10.42 0.000 798.6213 1168.831 ------------------------------------------------------------------------------ . tobit whrs kl6 k618 wa we, ll(0) nolog Tobit estimates Number of obs = 250 LR chi2(4) = 23.03 Prob > chi2 = 0.0001 Log likelihood = -1367.0903 Pseudo R2 = 0.0084 ------------------------------------------------------------------------------ whrs | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- kl6 | -827.7657 214.7407 -3.85 0.000 -1250.731 -404.8009 k618 | -140.0192 74.22303 -1.89 0.060 -286.2128 6.174543 wa | -24.97919 13.25639 -1.88 0.061 -51.08969 1.131316 we | 103.6896 41.82393 2.48 0.014 21.31093 186.0683 _cons | 589.0001 841.5467 0.70 0.485 -1068.556 2246.556 -------------+---------------------------------------------------------------- _se | 1309.909 82.73335 (Ancillary parameter) ------------------------------------------------------------------------------ Obs. summary: 100 left-censored observations at whrs<=0 150 uncensored observations . . end of do-file . exit, clear