--- On Thu, 16/4/09, Sachin Chintawar wrote:
> 1. Since I had generated 'ytrunc' as a truncated normal 
> distribution, then to know the bias I cannot tell Stata
> to generate 'ytrunc' based on a equation such as
>          y = b1 + b2*x + u
>      where b1 and b2 are specified. But if I do this then y
> goes to having a normal distribution and not a truncated
> normal distribution.
> 
> 2. Another problem is to develop a heteroskedastic error
> term. 
*------------------- begin example ----------------------
global numobs 500             // sample size N
global numsims "1000"         // number of simulations
set seed 678643594
capture program drop simtobit
program simtobit, rclass
	version 10.1
	drop _all
	set obs $numobs
	gen x = rnormal()
	gen z = rnormal()
	gen e = exp(1.5 + z)*rnormal()
	gen mu = 5 + x + z
	gen ystar = 5 + x +e 
	gen y = cond(ystar < 0, 0, ystar)
	tobit y x z, ll(0)
	return scalar b = _b[x]
	tempname z
	scalar `z' = abs((1-_b[x])/_se[x])
	return scalar p = 2*normal(-`z')
end
simulate b=r(b) p=r(p) , ///
    reps($numsims): simtobit
sum	
hist p, name(p) // should be uniform distribution
hist b, xline(1) name(b)
*------------------ end example ----------------------
Hope this helps,
Maarten
-----------------------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
      
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/