Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: Median and CI with predict

 From Nick Cox To "statalist@hsphsun2.harvard.edu" Subject Re: st: Median and CI with predict Date Fri, 7 Feb 2014 15:56:22 +0000

```I'd apply -ci- directly; indeed you have a choice of ways to do it.

But as for -glm-, my answer is the same answer as before:

1. -glm- gives you confidence intervals in its main output. The only
indirectness is that you need to invert the link.

2. -predict- is not needed.

Examples:

. sysuse auto
(1978 Automobile Data)

Iteration 0:   log likelihood = -53.942063
Iteration 1:   log likelihood = -47.679133
Iteration 2:   log likelihood = -47.065235
Iteration 3:   log likelihood = -47.065223
Iteration 4:   log likelihood = -47.065223

Generalized linear models                          No. of obs      =        74
Optimization     : ML                              Residual df     =        73
Scale parameter =  .2117734
Deviance         =  15.45945946                    (1/df) Deviance =  .2117734
Pearson          =  15.45945946                    (1/df) Pearson  =  .2117734

Variance function: V(u) = 1                        [Gaussian]
Link function    : g(u) = ln(u/(1-u))              [Logit]

AIC             =   1.29906
Log likelihood   = -47.06522292                    BIC             = -298.7373

------------------------------------------------------------------------------
|                 OIM
foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
_cons |  -.8602013   .2560692    -3.36   0.001    -1.362088   -.3583149
------------------------------------------------------------------------------

. mata: invlogit((-.8602013, -1.362088, -.3583149))
1             2             3
+-------------------------------------------+
1 |    .29729729   .2039011571   .4113675423  |
+-------------------------------------------+

. ci foreign, jeffreys binomial

----- Jeffreys -----
Variable |        Obs        Mean    Std. Err.       [95% Conf. Interval]
-------------+---------------------------------------------------------------
foreign |         74    .2972973    .0531331        .2024107    .4076909

. ci foreign, wilson binomial

------ Wilson ------
Variable |        Obs        Mean    Std. Err.       [95% Conf. Interval]
-------------+---------------------------------------------------------------
foreign |         74    .2972973    .0531331        .2052722    .4093291

Nick
njcoxstata@gmail.com

On 7 February 2014 15:45, Carla Guerriero <guerriero.carla@gmail.com> wrote:
> Hi Nick my dependent variable is a proportion (of the budget that
> given a budget constraint individuals are willing to give up)
> so I used  logit link function to ensure linearity and binomial family
> distribution.. For example for 19 in 100 risk reduction I get a
> coefficent of -.657211*** and If i use predict the mean WTP is 0.20
> which makes sense .. but the SD is 0 .. I want to get CI for the mean
> .. maybe boostrapping is an option? I know how to do for DCE where you
> have a ratio of the coefficent (delta or boostrapping or parametric
> boostrapping) but I have no clue how to make CI for eman WTP estimate
> from regression ..
>
>
> On Fri, Feb 7, 2014 at 4:26 PM, Nick Cox <njcoxstata@gmail.com> wrote:
>> -glm- with no covariates gives you confidence intervals for mean
>> response, directly or indirectly, depending on the link. No need to
>> use -predict- at all. I don't think you can get confidence  intervals
>> for the median that way.
>> *
>> *   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/
> *
> *   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/
*
*   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/
```