I have a problem that is more mathematical than Stata-related. I know this is a long shot, but I have to try.
- I am calculating a score (HS) which runs on a scale from 0% to 100%.
- HS should increase exponentially while state == 1.
- HS should decrease exponentially while state == 0
- HS should be 100% if state == 1, 91 t in a row. In other words if state == 1 for t1 to t91 (meaning the sum of state = 91), HS should be 100%.
Just for context, t = one day, and the 91 represents 3 months (365 / 12 * 3). The state refers to an occurrence that did (1) or did not (0) happen that day. If the occurrence happens 91 days in a row, HS must be 100%.
I don't know how to explain my problem better - which is probably why I haven't been successful finding a solution via Google.
Code if state == 1 for t1 to t91:
Code:
clear insobs 91 egen t = seq() gen state = 1 gen hs = (state*t^2)/(91^2)*100 twoway (line hs t)
Code:
clear insobs 91 egen t = seq() gen state = 0 gen hs = (91^2-(-t-(1))^2)/(91^2)*100 twoway (line hs t)
Array
Thank you so much in advance.
0 Response to Model that switches between exponential equations based on state variable
Post a Comment