Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: predict at observed values

From   Maarten buis <>
Subject   Re: st: predict at observed values
Date   Sun, 6 May 2007 22:29:02 +0100 (BST)

--- wrote:
> I am trying to get predicted values for caries2 (my dep var) at
> observed values of all exogenous var except seals. I can get
> predicted values for caries at mean of exogenous variables using 
> prvalue commands but do not know how to get it at observed values for
> each observation. I want to see how the prediction for caries2
> changes if everyone gets sealants (seals=1) while their other
> variables are at observed values. I ran the following code from an
> example by Scott Long somewhere online. I get the following error
> message "i: operator invalid." Can anyone please help by having a
> look at the following code and tell me where I am wrong? All my vars
> are binary except c_age which is continuous.

I don't think your code came through to the list, and you are not very
specific about where you found the code, but this example works:

*-------------- begin example ----------------
sysuse auto, clear
recode rep78 1/3=0 4/5 = 1
logit rep78 price mpg foreign

tempvar temp
gen `temp' = foreign

replace foreign = 1
predict pr1, pr
replace foreign = 0
predict pr0, pr

replace foreign = `temp'
predict pr, pr

sum pr0 pr1 pr
*---------------- end example ----------------
(For more on how to use examples I sent to the Statalist, see: )

Hope this helps,

Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.
*   For searches and help try:

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