I am wanting to use -predict- after -ologit- to put the predicted
probabilities into a set of temporary variables. I think my questions may
bring up enough issues about using temporary variables so as to be of more
general interest.
Questions:
1) How to use -predict- to store values in a list of tempvars .
Example:
use auto.dta
ologit rep78 price turn
local k = `e(k_cat)' /* save for future use
local ptop = "p`k'"
predict p1-`ptop'
This works fine, but what I would really like is to
get the predicted probabilities into a list of *tempvars.*
tempvar p1-`ptop'
is apparently not legal syntax.
So, I put all the the p1, ..., pk into a local macro, say plist,
using run time information about k, so I get plist = "p1 p2 p3 ... pk"
Then, I find that
tempvar `plist'
creates the list of temporary variables as desired,
but then I can't figure how to use `plist' to -predict-
the list of probabilities into the tempvars in plist.
So, what would be recommended as a way to get
a vector of predicted probabilities into a
list of tempvars? Perhaps my `plist' *can* be used?
2) Next, I have occasion to use these tempvars in loops.
As a simplifed,idealized code fragment to illustrate a confusion
I have experienced, consider
tempvar x1 x2 x3
foreach x of varlist `x1'-`x3' {
gen `x' = rand()
}
This generates an error message indicating that one of the
temporary variables is "not found", unless I assign values
to each of `x1'-`x3' by brute force prior to running the loop and then do a
-replace- rather than -gen- in the loop.
Clearly, I am missing some piece of understanding here as well.
I guess the question would be:
How to use a list of temporary variables in a loop if those temporary
variable do not yet have assigned values?
Regards,
=-=-=-=-=-=-=-=-=-=-=-=-=
Mike Lacy
Fort Collins CO USA
(970) 491-6721 office