Dear SAS Community,
I am working with an annual univariate time series consisting of 75 observations. I suspect that at observation 33, an intervention caused a downward shift in the mean of the series. My dataset contains a time variable labeled "Date" and a response variable "Yt".
In the code below, I define the target mean as the average of the first 32 observations, along with the corresponding estimate of the standard deviation. I then apply the CUSUM test to detect a potential mean shift.
Could you please review my approach and let me know if this is the correct way to detect a mean shift in the series using PROC CUSUM?
Thank you for your insights!
proc means data=a(obs=32); var Yt; output out=stats mean=mu0 std=sigma0; run; /* Store computed values as macro variables */ data _null_; set stats; call symputx("mu0", mu0); call symputx("sigma0", sigma0); run; ods graphics on; title 'Two-sided CUSUM Chart'; proc cusum data=a; xchart Yt*Date / mu0 = &mu0 sigma0 = &sigma0 delta = 2.6 alpha = 0.10; label Yt = 'Cumulative Sum'; run;
Yes, that's probably what you want. (As an aside, you can remove the traditional-graphics code options that are in there. The default now is for ODS Graphics to be enabled, which means older options for traditional graphics are ignored. You can omit all of the color options like CINFILL, and the SYMBOL statement is not applicable either.)
I think this is a reasonable approach, but to detect a downward shift you probably want a one-sided scheme instead and a negative delta. You can add SCHEME=ONESIDED in the XCHART options. For a one-sided scheme, you need to specify the height of the decision interval with the H= option and omit the ALPHA= option. There is some discussion here and see also "Designing a CUSUM scheme"
Thank you Zard for your valuable advice.
Do you think the code below is correct for the problem I have? I mostly copied it from Chapter 7: The CUSUM Procedure (p. 562).
proc means data=a(obs=33); var Yt; output out=stats mean=mu0 std=sigma0; run;
data _null_;
set stats;
call symputx("mu0", mu0);
call symputx("sigma0", sigma0);
run;
options nogstyle;
goptions ftext='albany amt';
symbol v=dot color=salmon h=1.8 pct;
title "One-Sided Cusum Analysis";
proc cusum data=a;
xchart Yt*Date/
mu0=&mu0
sigma0=&sigma0
delta=-1
h=4
k=0.5
scheme=onesided
tableall
cinfill = ywh
cframe = bigb
cout = salmon
cconnect = salmon
climits = black
coutfill = bilg;
label Yt = 'Cusum of Yt';
run;
options gstyle;
Thanks.
Yes, that's probably what you want. (As an aside, you can remove the traditional-graphics code options that are in there. The default now is for ODS Graphics to be enabled, which means older options for traditional graphics are ignored. You can omit all of the color options like CINFILL, and the SYMBOL statement is not applicable either.)
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.