Bookmark and Share

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


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

Re: st: predict after logit


From   Sara Borelli <[email protected]>
To   [email protected]
Subject   Re: st: predict after logit
Date   Fri, 13 Jul 2012 15:06:02 -0400

Tim,
thank you very much for your help, this is very helpful
Sara


On Thu, Jul 12, 2012 at 3:39 PM, Tim Wade <[email protected]> wrote:
> Without having margins, you can always use a bootstrap, need to check
> the syntax for -bootstrap- in version 10.
>
> sysuse auto.dta
>
> xtile hiprice=price, nq(2)
>
>
> program bootphat, rclass
> logistic  foreign hiprice mpg
> tempvar phat
> predict `phat'
> qui summ(`phat')
> return scalar pm=r(mean)
> qui summ(`phat') if hiprice==1
> return scalar plo=r(mean)
> qui summ(`phat') if hiprice==2
> return scalar phi=r(mean)
> end
>
>
>
> bootstrap pmean=r(pm)  phi=r(phi) plo=r(plo), reps(1000): bootphat
>
>
>
>
>
> On Thu, Jul 12, 2012 at 2:08 PM, Sara Borelli <[email protected]> wrote:
>> thank you Tim for the suggestion,
>> I cannot find the margins options...may it be because this is a new
>> feature of STATA ?
>> I am using stata 10
>> thanks
>> Sara
>>
>>
>> On Wed, Jul 11, 2012 at 5:27 PM, Tim Wade <[email protected]> wrote:
>>> apologies,  the first segment of code  should read:
>>>
>>> sysuse auto.dta
>>> xtile hiprice=price, nq(2)
>>> logistic foreign hiprice mpg
>>> margins, by(hiprice)
>>>
>>>
>>> On Wed, Jul 11, 2012 at 5:26 PM, Tim Wade <[email protected]> wrote:
>>>> If I understand what you are asking, I think margins does this:
>>>>
>>>> margins, by(hiprice)
>>>> sysuse auto.dta
>>>> xtile hiprice=price, nq(2)
>>>> logistic foreign hiprice mpg
>>>> margins, by(hiprice)
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>>              |            Delta-method
>>>>              |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
>>>> -------------+----------------------------------------------------------------
>>>>      hiprice |
>>>>           1  |   .2162162   .0557663     3.88   0.000     .1069163    .3255161
>>>>           2  |   .3783784   .0681487     5.55   0.000     .2448094    .5119474
>>>> ------------------------------------------------------------------------------
>>>>
>>>>
>>>> note this margin estimates are the same as the means of phat:
>>>>
>>>> logistic foreign hiprice mpg
>>>> predict phat
>>>> tabulate hiprice, summ(phat)
>>>>
>>>>
>>>> 2 quantiles |       Summary of Pr(foreign)
>>>>    of price |        Mean   Std. Dev.       Freq.
>>>> ------------+------------------------------------
>>>>           1 |   .21621622   .23645819          37
>>>>           2 |   .37837838   .25520846          37
>>>> ------------+------------------------------------
>>>>       Total |    .2972973   .25759862          74
>>>>
>>>> Tim
>>>>
>>>>
>>>> On Wed, Jul 11, 2012 at 1:01 PM, Sara Borelli <[email protected]> wrote:
>>>>> Hi all,
>>>>> I am running a logit model to obtain a predicted probability for each
>>>>> individual (phat_i)  using predict, pr command .
>>>>>
>>>>>  I have to calculate the average of  this prediction within some
>>>>> categories of a variable x:
>>>>>  mean_phat_i=mean( phat_i)  by(x)
>>>>> and obtain standard errors and confidence interval for this mean.
>>>>>
>>>>> I know I can use adjust for this purpose, but I also need to calculate
>>>>> standard errors/confidence intervals  for mean_phat_i
>>>>>
>>>>> Thanks in advance for any insight
>>>>>
>>>>> Sara
>>>>> *
>>>>> *   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/
>>> *
>>> *   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/
>> *
>> *   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/
> *
> *   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/
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index