Vitor <[email protected]>:
-prvalue- is some user-written code, I guess
(http://www.indiana.edu/~jslsoc/spost.htm)?
I'm not quite sure what standard error you want--but it seems plain
that -mfx- has nothing to do with it. You can use the formulas in
May's email mechanically to plug into -nlcom- and get a point estimate
and SE on anything, I suppose. However, the estimate of y conditional
on y>0 (and its SE) and X equal to the sample mean of X need not
*mean* anything in particular--the mean of X could even be an
infeasible value for X, so not a particularly interesting point at
which to calculate predictions. More interesting is to calculate
predictions at every observed value of X.
That said, try this on for size [aside: can anyone give an easier method?]:
clear
sysuse auto
replace mpg=mpg-20
version 7
tobit mpg len, ll(0)
predict xb,xb
predict y, ystar(0,.)
la var y "E(y|x) unconditional expected y"
predict e, e(0,.)
la var e "E(y|x,y>0) conditional on y being uncensored, from predict"
predict p, pr(0,.)
la var p "E(y>0) probability uncensored"
gen m_e=xb+_b[_se]*normden((0-xb)/_b[_se])/norm(-((0-xb)/_b[_se]))
la var m_e "E(y) conditional on y being uncensored, manual calc"
su e m_e
su len, meanonly
loc v=r(mean)
local xb="(`v'*_b[len]+_b[_cons])"
di "Estimate of E(y|x=E(X),y>0) and its SE"
nlcom `xb'+_b[_se]*normden((-`xb')/_b[_se])/norm((`xb')/_b[_se])
di "Now get SE for two types of predictions for each obs:"
predict stdp, stdp
g hixb=xb+1.96*stdp
g loxb=xb-1.96*stdp
g se=.
loc n=_N
qui {
forv i=1/`n' {
su len in `i', meanonly
loc v=r(mean)
local xb="(`v'*_b[len]+_b[_cons])"
nlcom `xb'+_b[_se]*normden((-`xb')/_b[_se])/norm((`xb')/_b[_se])
mat v=r(V)
replace se=sqrt(v[1,1]) in `i'
}
}
g hie=e+1.96*se
g loe=e-1.96*se
version 8.2
sort len
tw rarea hixb loxb len || scatter xb len, yli(0) c(l) name(xb)
tw rarea hie loe len || scatter e len, yli(0) c(l) name(e)
gr combine xb e, ycommon
On 7/26/07, [email protected] <[email protected]> wrote:
I have a problem estimating predicted values that is
somehow related to the messages fro Lisa and May
below.
I estimated I tobit model and I want E(y|x,y>0)
conditional on vector x on its mean values. After
reading the messages below I understand that the
following command gives me what I want:
mfx compute, predict(e(0,.))
(It also gives me the marginal effects, but I don't
need them)
My problem is that mfx does not give me the Standard
Error of E(y|x,y>0). And I need this.
I have tried the prvalue command. Simply typing
"prvalue", with no options", it gives me the predicted
value and a confidence interval, which would be
enough. But what prvalue estimate is E(y|x), and not
E(y|x,y>0).
Does anyone know how to make prvalue estimate
E(y|x,y>0) after a Tobit model, rather than E(y|x)?
Or is there another way to do what I want?
Or am I getting it all wrong from the beginning and my
question makes no sense at all?!..
----- Original Message -----
From: May Boggess <[email protected]>
Date: 03 Jan 2005 16:57:24 -0600
On Monday, Lisa wrote:
For the following command:
tobit facil4p $demo5, ll(0);
mfx compute, predict(e(0,.));
does this give marginal effects in terms of
1) E(y|x,y>0) OR 2) E(y|x) = P(y>0) * E(y|x,y>0)
If it is (1) (which I am pretty sure that it is)
could someone please tell me how to specify (2) in STATA.
It gives (1). Here is an example that shows how the various
predictions available after -tobit- are calculated:
clear
sysuse auto
replace mpg=mpg-20
version 7
tobit mpg len, ll(0)
predict xb,xb
predict y, ystar(0,.)
la var y "Unconditional Expected Value"
predict e, e(0,.)
la var e "Conditional on being Uncensored"
predict p, pr(0,.)
la var p "Probability Uncensored"
gen myy = p*e
sum y myy
gen mye = xb + _b[_se]*normden((0-xb)/_b[_se])/p
sum e mye
gen myp = norm(-((0-xb)/_b[_se]))
sum p myp
This shows that ystar is the function Lisa is looking for in (2).
That means she can calculate the marginal effect, and its standard
error, as follows:
mfx, predict(ystar(0,.))
--May
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/