* ***************************************************************** *
* ***************************************************************** *
* File-Name: Tobit_Pr(y_greaterthan_c).do *
* Date: October 13, 2011 *
* Author: Travis Braidwood, Florida State University *
* tbraidwood@fsu.edu *
* Purpose: probability of exceeding the censorship point *
* Input File: n/a.dta, data is STATA generated *
* Data Output: None *
* Prev. file: None *
* Accompanying file: n/a *
* Machine: Office *
* **************************************************************** *
* **************************************************************** *
********************************************************************************
/*
A note to users: Tobit offers several specifications (See Cameron and Trivedi
2005; Breen 1996). This .do file addresses one of those specifications: the
probability of the estimate exceeding the censorship point (Breen 1996).
The equations offered may be used regardless of the censor point, however for
truncated data users should consult the aforementioned econometric resources,
or another of their choosing.
*/
********************************************************************************
clear all
set seed 0210
set obs 1000
set scheme s1mono
set more off, perm
version 11
*
gen y = rnormal(5)*.25
gen x1 = runiform()*.25
gen x2 = runiform()*-2
gen x3 = runiform()*2.5
sum
replace y=0 if y<=1
/* we've purposefully censored some data at 0, let's assume it could
actually be negative */
*
*Now let's compair regression to tobit (this Tobit gives us E(y*|x), which = x'B)
reg y x1 x2 x3
tobit y x1 x2 x3, ll(0)
preserve //preserve variables so we can restore later
*
*Let's draw some simulated coeffs from the tobit model (above)
drawnorm tb1-tb5, n(10000) means(e(b)) cov(e(V)) clear
/* note that above you will need to change the number of "tb" variables produced
depending on the number of independent variables in your model. "tb" will need
to equal n+2, where n is the number of independent variables. Example: here
there are (n=3)+2=5*/
save simulated_betas, replace
restore
merge using simulated_betas
drop _merge
*
/* Now need to set the values we are interested in. Here we want to know x2
from min to max*/
*
local a = -1.996294 //the min
scalar x1 = .1258682 //mean
scalar x3 = 1.254568 //mean
scalar constant = 1
*
/* now let's calculate Pr[y>c], probability of exceeding the censor point.*/
postutil clear
postfile mypost Ey upper lower using simresults, replace
noisily display "start"
set obs 10000
while `a' <= -.0047823 /* which is the max for x2 */ {
qui gen xb = tb1*x1 + tb2*`a' + tb3*x3 + tb4*constant
qui gen s = tb5 //sigma
qui gen c = 0 //the censoring point
qui gen invmills = normalden(xb/s)/normal(xb/s) //inverse mills ratio
qui gen d = (xb-c)/s //not used here, but will be in other tobit specifications
qui gen Ey = normal((xb/s))
_pctile Ey, p(2.5,97.5) //now 95% confidence intervals
scalar upper = r(r1)
scalar lower = r(r2)
post mypost (Ey) (upper) (lower)
local a = `a'+.05 // the amount we will increase x2 by
drop xb s c invmills d Ey //drop all values so we can begin the loop again
display "." _c
}
display ""
*
postclose mypost
use simresults, clear
*
sum
gen MV = (_n-1)
*
graph twoway line Ey MV, clwidth(medium) clcolor(navy) clpattern(solid) ///
|| line lower MV, clpattern(dash) clwidth(thin) clcolor(maroon) ///
|| line upper MV, clpattern(dash) clwidth(thin) clcolor(maroon) ///
ytitle(Y-Axis Label) xtitle(X-Axis Label)