Statalist


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

Re: st: RE: predict with if and option


From   Steven Samuels <[email protected]>
To   [email protected]
Subject   Re: st: RE: predict with if and option
Date   Mon, 11 Feb 2008 16:55:40 -0500

It looks like you are trying to run the -predict- statement inside some kind of double loop. I don't know the innards of -predict-, but I'd guess it is trying to create the same variable for every value of the loop arguments. If you had done "generate temp =foobar" inside a loop, this would generate an error that the 'variable already exists'; perhaps your error is the same. If the loop did the prediction for the first time through on both arguments, that's the problem. There are many possible solutions, including naming the new variable by appending "i" and "t".

Maybe: "predict temp`i'`t' if ..."

Statalist FAQ state that you should show all the commands and all the output that Stata generated. As Nick states, you haven't listed enough for us to really know what went wrong.

-Steven
[email protected]



On Feb 11, 2008, at 4:35 PM, Nick Cox wrote:


This worked for me.

sysuse auto
regress mpg weight
predict foobar if rep78 < 3, stdp

I guess that you are doing something different that you are not
telling us, e.g. using a command other than -regress-.

Nick
[email protected]

William Bishop

I would like to run predict with the IF condition after a regression,
using the stdp option at the same time but am getting the error
"option stdp not allowed"

predict temp if id=="`i'"&n==`t', stdp

seems pretty basic.  what am I missing?  maybe I misunderstood the
documentation on predict, but I thought this was doable.

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