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 09:53:31 -0400
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/