Statalist


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

st: Output summary stats before doing other iteration


From   Larraine Becker <lbecker@unimelb.edu.au>
To   statalist@hsphsun2.harvard.edu
Subject   st: Output summary stats before doing other iteration
Date   Fri, 12 Sep 2008 16:34:53 +1000

Hi all,

 

I’m doing 1000 iterations of a logistic regression.  I have to output the predicted value each time before it carries on with the next iteration, otherwise I lose the

first 999 predicted values!  I’m sure there is a way to go about this, but how can I save the predicted value each time so I end up with a table with 1000 predicted values?

 

My program is as follows:

 

forvalues i=1(1)10 {

use "U:\CS\combined dataset_2006.dta", clear

generate random`i' = uniform()

sort anyprevcs random`i'

generate dropouts = 0

replace dropouts =1 if anyprevcs==1 & (_N - _n) < 3575

 

logit …….(I’ve deleted the variables, as there are too many to put here!)

 

replace anyprevcs=0 if dropouts==1

predict onehat`i'

summarize onehat`i'

gen n=_n

egen predicted`i'=mean(onehat`i')*n

drop dropouts n

}

 

Thanks,

Larraine




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