Hi everyone, I'm trying to solve the time taken for an equation to meet a condition (to be greater than quartile90). I want to do this for 471 different equations. the equation I am testing is:
I have got two loops, the first separates each event and generates a count variable specific to it.
The second loop is a 'while' loop that has the stopping condition
the first (countnew`j' < quartile90) is what i want to find and the second is too stop it if the first condition is not meet.
Unfortunately it gets stuck in a seemingly infinite loop.
My question is what have I done wrong and is there a way to do this so i have one time count and y variable (countnew`j') rather than 471 of them.
Code:
y = beta + estimate1*(time`j') + estimate2*(time`j'^2) + estimate3*(time`j'^3)
The second loop is a 'while' loop that has the stopping condition
Code:
while (countnew`j' < quartile90) & (time`j'<630) {
Unfortunately it gets stuck in a seemingly infinite loop.
My question is what have I done wrong and is there a way to do this so i have one time count and y variable (countnew`j') rather than 471 of them.
Code:
forvalues j = 1/471 { gen countnew`j' = 0 gen time`j' = 0 while (countnew`j' < quartile90) & (time`j'<630) { replace countnew`j' = beta + estimate1*(time`j') + estimate2*(time`j'^2) + estimate3*(time`j'^3) if indicator==`j' replace time`j'= time`j' + 1 if indicator==`j' } replace time`j'= time`j' - 1 if indicator==`j' }