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

Re: st: Re: statalist-digest V4 #1868

From   Joseph Coveney <[email protected]>
To   Statalist <[email protected]>
Subject   Re: st: Re: statalist-digest V4 #1868
Date   Sun, 30 Jan 2005 13:35:20 +0900

Mike Lacy wrote:

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.


1) How to use -predict- to store values in a list of tempvars .


2) Next, I have occasion to use these tempvars in loops.


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?


Take a look at the following do-file and see whether it answers your questions.

Joseph Coveney

P.S. Consider using a descriptive subject line in your post.

tempvar tmpvar
sysuse auto, clear
ologit rep78 price turn
* Begin Question 1) here
local cat_max = e(k_cat)
local varlist = ""
forvalues i = 1/`cat_max' {
    local varlist `varlist' `tmpvar'`i'
display "`varlist'"
predict `varlist'
* End Question 1)--Begin Question 2) here
generate float latent_var = uniform()
foreach var of varlist `varlist' {
    generate byte sco_`var' = (latent_var > `var')
egen byte sco = rsum(sco_*)
slist _* sco_* sco, noobs

*   For searches and help try:

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