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: Predicted values where a subgroup of variables are held constant


From   Tim Wade <[email protected]>
To   [email protected]
Subject   Re: st: Predicted values where a subgroup of variables are held constant
Date   Fri, 18 Mar 2011 13:50:09 -0400

Note that the "by(mpg price)" is not necessary in the adjust
command-leaving it out results in the same predicted results


On Fri, Mar 18, 2011 at 1:46 PM, Tim Wade <[email protected]> wrote:
> Margins and adjust can allow practically any combination you want-How
> about this?
>
> sysuse auto.dta
> logistic foreign  mpg price weight length
> *weight and length at means
> adjust weight length, by(mpg price) gen(phat) pr
> list mpg price if price==3291
> *same result with margins
> margins, atmeans at(mpg=20 price=3291)
>
> Tim
>
> On Fri, Mar 18, 2011 at 10:08 AM, Michael Harhay
> <[email protected]> wrote:
>> Hi Tim,
>> Thank you for responding. I think this is close, but am having a tough
>> time translating specifically to my model. I don't think it is exactly
>> as I don't want to predict based on only one level of one co variate.
>>
>> let me try and outline better my case and sorry if it is the same.
>>
>> We are trying to predict an adjusted individual probability of being
>> re-hospitalized.
>>
>> Our outcome is binary, but I was using OLS to try and work out the
>> coding for the moment.
>>
>> Step 1:  I regress rehosp using patient characteristics, hospital
>> characteriscts and local market characteristics
>>
>>    regress rehosp $patient $hospital $market
>>
>> my PI would like me to do something that would work like this if the
>> code allowed
>>
>>    predict y, xb at((means) hospital market)
>>
>> So we want to keep all the controls in the global command for hospital
>> and market at their means but let the prediction vary at the
>> individual level.
>>
>> -Michael
>>
>>
>>
>>
>> On Fri, Mar 18, 2011 at 9:53 AM, Tim Wade <[email protected]> wrote:
>>> Is something like this what you are looking for?
>>>
>>> sysuse auto.dta
>>> regress price  mpg gear_ratio length weight
>>> *price with covariates at means and mpg at 20
>>> margins, at((mean) _all mpg=20)
>>> *generate predicted results at means for each observation of mpg
>>> adjust gear_ratio length weight, gen(yhat)
>>> *confirm result is same for margins
>>> list yhat if mpg==20
>>>
>>>
>>> Tim
>>>
>>>
>>> On Thu, Mar 17, 2011 at 5:11 PM, Michael Harhay
>>> <[email protected]> wrote:
>>>> Dear all,
>>>> I want to do a straightforward xb prediction after an OLS regression
>>>> on a patient population, but for a subgroup of variables I want to use
>>>> the sample mean not the true individual value for the prediction:
>>>> I've been playing with both the "predict" and "margins" command but
>>>> with no success. Is there an "if" like command I can put after predict
>>>> to force this?
>>>> After no success trying that I also tried to go about this in a roundabout way:
>>>> preserve
>>>> foreach var of local varlist `pred' {
>>>>    sum `var’, meanonly
>>>>    replace `var’ = r(mean)
>>>>    }
>>>>
>>>> predict sev5, xb
>>>> The predictions are still not adjusted.
>>>> Any quick thoughts?
>>>> Thanks!
>>>>
>>>> *
>>>> *   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