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

st: Re: predict using a subset of X

From   "Michael Blasnik" <>
To   <>
Subject   st: Re: predict using a subset of X
Date   Sun, 13 Jun 2004 19:23:33 -0400

It's not clear what you mean 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

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

----- Original Message ----- 
From: "Dimitriy V. Masterov" <>
To: <>
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)?
> 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:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index