Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Help glm, fam(gamma)


From   [email protected] (Roberto G. Gutierrez, StataCorp.)
To   [email protected]
Subject   Re: st: Help glm, fam(gamma)
Date   Fri, 31 Jan 2003 11:12:50 -0600

Mike Schmader <[email protected]> asks:

> I am modeling healthcare costs using a glm with gamma distribution and the
> log link:

> glm y x1 x2 x3, fam(gamma) link(log)

> The coefficients are displayed in log terms. When I predict the mean costs
> for the sample {mu as the default; y_hat = g_inverse(xb)}, the means are
> displayed in monetary terms as desired.

> How can I obtain the 95% confidence intervals for the predicted means?  I've
> tried the command:

> predict se_mean, stdp

> but this does not give me the SE's around the predicted means.

Since the mean is just the exponeniated linear predictor in this case, 
you can easily get the standard error of the mean via

   . glm y x1 x2 x3, fam(gamma) link(log)
   . predict mu
   . predict se_xbeta, stdp
   . gen mu_se = mu*se_xbeta 

where -mu_se- are the standard errors you seek.  This was easy because exp(x)
is its own derivative.  Sometimes the delta method calculation is not so 
easy, in which case in Stata 8

   . glm y x1 x2 x3, fam(gamma) link(log)
   . predictnl mu = predict(), se(mu_se)

would do all this automatically.  The term -predict()- in the above simply
means that I want the default prediction for -glm-.

As for confidence intervals, there are two ways you can go.

    (1) use -mu- and -mu_se- and construct mu +/- Z*mu_se
    (2) obtain the linear predictor, -xbeta-, construct 

                  xbeta +/- Z*xbeta_se

	and then exponentiate the endpoints.

If using lots of predictors, (2) should have better small sample properties.
However (2) only works because the transformation, exp(x), is monotone.  (1)
works generally.

Again, in Stata 8 you can automatically implement (1):

    . predictnl mu = predict(), ci(mu_left mu_right) level(95)

--Bobby
[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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index