Hi Ian,
thanks for the script. I see that it's working with Data Unit option set to 1. Apart from scaling I get the same result for the sum or the mean if I dont't use data units. That's what I expected. However, the chart for the raw data looks different when setting data units to 0 (see attached image). Can you explain this?
This is my script:
NamesDefaultToHere(1);
ng = 10; // Number of groups
ns = 5; // Size of group
// Make some data
sVals = SortAscending(Repeat((1::ng)`, ns));
cVals = J(ng*ns, 1, RandomInteger(0, 20));
dt1 = NewTable("Raw Data",
NewColumn("Group", Numeric, Ordinal, Values(sVals)),
NewColumn("Count", Numeric, Continuous, Values(cVals))
);
// Do the Cusum Control Chart (note the 'Data Units' option)
dt1 << CUSUM Control Chart(Y( :Count ), X( :Group ), Show Center Line( 0 ), Data Units( 1 ));
dt1 << CUSUM Control Chart(Y( :Count ), X( :Group ), Show Center Line( 0 ), Data Units( 0 ));
// Agregate the data (use the 'sum' not the 'mean'!)
dt2 = dt1 << Summary(Group( :Group ), Mean( :Count ));
// Do the Cusum Control Chart with the agregated data (note the 'Data Units' option)
dt2 << CUSUM Control Chart( Y( :"Mean(Count)"n ), Show Center Line( 0 ), Data Units( 1 ));
dt2 << CUSUM Control Chart( Y( :"Mean(Count)"n ), Show Center Line( 0 ), Data Units( 0 ));
// Agregate the data (use the 'sum' not the 'mean'!)
dt3 = dt1 << Summary(Group( :Group ), Sum( :Count ));
// Do the Cusum Control Chart with the agregated data (note the 'Data Units' option)
dt3 << CUSUM Control Chart( Y( :"Sum(Count)"n ), Show Center Line( 0 ), Data Units( 1 ));
dt3 << CUSUM Control Chart( Y( :"Sum(Count)"n ), Show Center Line( 0 ), Data Units( 0 ));