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

Re: st: Re: predict using a subset of X


From   "Dimitriy V. Masterov" <[email protected]>
To   [email protected]
Subject   Re: st: Re: predict using a subset of X
Date   Sun, 13 Jun 2004 19:33:31 -0500 (CDT)

Thanks to Michael Blasnik for speedy help. The reason I wanted to do this
is that I want to construct a residualized test score yhat that is
stripped from the effect of some covariates like age. I do agree that my
notation was a bit awkward. I modified his suggested code to work without
manual counting:

local subset "x*";
unab subset : `subset'
scalar LLL=wordcount("`subset'")

reg y `subset' z1 c1 d1 f1 age
mat b=e(b)
mat b=b[1,1..LLL]
mat score yhat=b if e(sample)




On Sun, 13 Jun 2004, Michael Blasnik wrote:

> It's not clear what you mean here...you say you want to generate
> E[y|x1,...,x50], but that would be the result from -predict- after
> running -reg y x1...x50-, not running the model you show.  What would you
> want predict to do about the fact that there are 50 other terms in the model
> that you don't want in the prediction?  There is generally no reason to
> think the predictions will have much to do with E[y].
>
> If you just want an Xb prediction with only a subset of b, you could copy
> e(b) to a matrix, create a submatrix with only the terms you want (do you
> want the constant?), and then use matrix score to have Stata calculate the
> "prediction".
>
> reg y x1...x100
> mat b=e(b)
> mat b=b[1,1..50]
> mat score mypredict=b
>
> mypredict will contain the prediction from the first 50 terms, but won't
> include the remain 50 xs or the constant (which Stata puts last).
>
> Michael Blasnik
> [email protected]
>
>
> ----- Original Message -----
> From: "Dimitriy V. Masterov" <[email protected]>
> To: <[email protected]>
> Sent: Sunday, June 13, 2004 6:57 PM
> Subject: st: predict using a subset of X
>
>
> > Is it possible to automatically generate a yhat for a subset of the RHS
> > variables?
> >
> > Let's say I run a regression:
> >
> > reg y x1 x2 .... x100
> >
> > I want to generate
> > yhat=E[y | x1,...,x50]
> > rather than
> > yhat=E[y|x1,...,x100]
> >
> > Is there some option like predict yhat, for(x1-x50)?
> >
> > DVM
> >
> >
> ____________________________________________________________________________
> ___
> > Dimitriy V. Masterov
> >
> > Work:
> > Center for Social Program Evaluation
> > 1155 East 60th St. Room 038
> > Chicago, IL 60637
> > Work: (773)256-6005
> > Fax: (773)256-6313
> >
> > Home:
> > 1312 East 53rd St., Apt.309
> > Chicago, IL 60615
> > Mobile: (773)220-2760
>
>
> *
> *   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/
>

_______________________________________________________________________________
Dimitriy V. Masterov

Work:
Center for Social Program Evaluation
1155 East 60th St. Room 038
Chicago, IL 60637
Work: (773)256-6005
Fax: (773)256-6313

Home:
1312 East 53rd St., Apt.309
Chicago, IL 60615
Mobile: (773)220-2760


*
*   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