Hello again. I am rephrasing my question in the hope that I can make the frustration go away.
Row | R | Cases |
1 | . | [1, 1, 2, 1] |
2 | 1.4 | |
3 | 1.67 | |
4 | 2.3 | |
I have 2 columns, R and Cases. Cases are calculated by multiplying R from the current row with Cases from the previous row. In addition, R needs to be modified (reduced) based on the sum of Cases from the previous row.
R (row2) in column Cases = R (row2) * modifier
modifier = 1 - ((cumulative sum of Cases from row1 to the row before the current row * 4)/Total Population)
Total Population is a parameter and is 100.
The resulting modifier is multiplied with Cases from row1 to create Cases in row2.
For instance, I am expecting the modified R (row2) to be 1.12 and Cases (row2) to be [1.12, 1.12, 2.24, 1.12]
1.4 * 1 - (5 * 4/100) = 1.12
1.12 * [1, 1, 2, 1] = [1.12, 1.12, 2.24, 1.12]
Then, I expect the modified R (row3) to be 0.71 and Cases (row3) to be [0.8, 0.8, 1.6, 0.8]
1.67 * 1 - (10.6 * 4/100) = 0.71
10.6 is from 5 cases in row1 and 5.6 cases in row2.
0.71 * [1.12, 1.12, 2.24, 1.12] = [0.8, 0.8, 1.6, 0.8]
I am having a problem in getting the green value. My current attempt at writing a JMP script is as follows.
If( Row() == 1,
Matrix( {1, 1, 2, 1} ),
:R * (1 - (Summation( i = 1, N Row() - 1, Sum( :Cases ) ) * 4) / Total Population) * Lag( :Cases, 1 )
)
I tried Index, Lag, Row() - 1, Col cumulative sum, Summation, etc to get the modifier, and nothing has worked. I mainly get either
1) illegal referencing or
2) unsubscriptable
Thank you once again for your time and expertise.