07-12-2013 09:01 PM
How to I compute this from data above.?
Z=SUM(S(X_i)-S_i+1)*(X_i+1 - X_i)
Z=(0.91-0.85)(2-1) + (0.85-0.76)(3-2) + (0.76-0.61)(4-3) + (0.61-0.55)(5-4)
Z=SUM[(S(X_i)-S_i+1) * (X_i+1 - X_i)]
Please in case of simulations
In a general setting such that;
For Example how do I used the code above for this case that I simulate;
Do i=1 to 100;
07-18-2013 10:10 AM
Since this is the IML subforum, lets assume your data is stored in a matrix named SDATA.
do i=1 to (nrow(SDATA)-1);
a more efficient way would probably be to use 4 temporary matrices of dimension (nrow(SDATA)-1) and define them like X1=SDATA[1:nrow(SDATA)-1,2], X2=SDATA[2:nrow(SDATA), 2] etc. and use term by term multiplication operator which I forgot on the top of my head as it's been a while since I've used IML. More memory usage but fewer operations.
if you want to do this in regular SAS, look for lag<n> function, in your case lag1 function.