Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Two-Part Modeling: Using -margins- command to calculate predicted cost and confidence intervals


From   "Weichle, Thomas" <Thomas.Weichle@va.gov>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Two-Part Modeling: Using -margins- command to calculate predicted cost and confidence intervals
Date   Wed, 31 Oct 2012 15:29:24 -0500

Hi Statalisters,

I'd like to describe the processes I'm doing using Stata to try to
estimate a confidence interval around the predicted value of cost for
some particular set of independent variables.  My main concern is if it
makes sense conceptually.  The Stata command -margins- appears to allow
me to compute the predicted cost in a two-part model with confidence
intervals.  The following are my steps:

Predicted cost in two-part model (predicted value of Y):
E(Y|X) = P(Y>0|X)*E(Y|Y>0, X) where P(Y>0|X) is the probability of any
cost being incurred (Part 1) and E(Y|Y>0, X) is the predicted cost
conditional on incurring any cost (Part 2)

Part 1 Stata calculation:
** Create indicator for whether or not individual incurred cost **
generate nonzero_cost = 0
replace nonzero_cost = 1 if cost != 0
** P(Y>0|X) **
logistic nonzero_cost i.exposure_var independent_var1 independent_var2
independent_var3
predict phat if e(sample), pr

Part 2 Stata calculation:
** E(Y|Y>0, X) **
glm cost i.exposure_var independent_var1 independent_var2
independent_var3 if cost > 0, family(gamma) link(log) eform nolog 
predict mu if e(sample), mu

Predicted cost in two-part model Stata calculation (combining Parts 1 &
2):
** E(Y|X) = P(Y>0|X)*E(Y|Y>0, X) **
margins, dydx(exposure_var) expression(phat*predict(mu)) post

My question is the following:
Conceptually, is it an accurate approach to use the -margins- command to
calculate the predicted cost and confidence interval around the
predicted cost?  Another concern of mine is whether the calculation of
the standard errors is reasonable.  Margins uses the delta-method for
calculation of standard errors.

Tom Weichle
Math Statistician
VA Information Resource Center (VIReC)
Edward Hines Jr. VA Hospital, Bldg 18, 202E
708-202-8387 ext. 24261
Thomas.Weichle@va.gov 


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index