Created
September 30, 2021 08:54
-
-
Save MJacobs1985/cb3fc2d8ed73af27e0d84b9b7203ff68 to your computer and use it in GitHub Desktop.
Time-series analysis in SAS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Female 65-80 */ | |
ods noproctitle; | |
ods graphics / imagemap=on; | |
proc sort data=WORK.MONTH out=Work.preProcessedData;by date;run; | |
proc ucm data=Work.preProcessedData; | |
id date interval=month; | |
deplag lags=(9 14 19 20); | |
cycle order=2 plot=smooth; | |
model '65_80_female'n; | |
level plot=smooth; | |
slope plot=smooth; | |
irregular pllot=smooth; | |
season length=12 type=trig; | |
estimate plot=(panel acf histogram qq residual model) outest=work.outest0001; | |
forecast lead=44 back=24 alpha=0.05 plot=(forecasts decomp decompvar fdecomp fdecompvar) outfor=work.outfor; | |
performance threads=16; | |
outlier; | |
nloptions maxiter=500; | |
run; | |
proc delete data=Work.preProcessedData;run; | |
ods graphics / imagefmt=svg width=10in height=5in; | |
proc sgplot data=outfor noautolegend; | |
series x=date y='65_80_female'n / lineattrs=(color=black thickness=1) legendlabel="Female Mortality" name="ICU"; | |
series x=date y=forecast / lineattrs=(color=blue) legendlabel="Forecasted" name="f"; | |
band x=date lower=LCL upper=UCL / transparency=0.9 fillattrs=(color=blue) legendlabel="95% Confidence Interval" name="CI"; | |
xaxis type=time label='Time (days)' grid minor; | |
yaxis label='Mortality' grid; | |
keylegend "ICU" "f" "CI"; | |
title 'UCM model to predict female mortality for 65-80'; | |
run; | |
/* Male 65-80 */ | |
ods noproctitle; | |
ods graphics / imagemap=on; | |
proc sort data=WORK.MONTH out=Work.preProcessedData;by date;run; | |
proc ucm data=Work.preProcessedData; | |
id date interval=month; | |
deplag lags=(9 25); | |
model '65_80_male'n; | |
level plot=smooth; | |
slope plot=smooth; | |
irregular plot=smooth; | |
season length=12 type=trig; | |
estimate plot=(panel acf histogram qq residual model) outest=work.outest0001; | |
forecast lead=44 back=24 alpha=0.05 plot=(forecasts decomp decompvar fdecomp fdecompvar) outfor=work.outfor; | |
performance threads=16; | |
outlier; | |
nloptions maxiter=500; | |
run; | |
proc delete data=Work.preProcessedData;run; | |
ods graphics / imagefmt=svg width=10in height=5in; | |
proc sgplot data=outfor noautolegend; | |
series x=date y='65_80_male'n / lineattrs=(color=black thickness=1) legendlabel="Male Mortality" name="ICU"; | |
series x=date y=forecast / lineattrs=(color=blue) legendlabel="Forecasted" name="f"; | |
band x=date lower=LCL upper=UCL / transparency=0.9 fillattrs=(color=blue) legendlabel="95% Confidence Interval" name="CI"; | |
xaxis type=time label='Time (days)' grid minor; | |
yaxis label='Mortality' grid; | |
keylegend "ICU" "f" "CI"; | |
title 'UCM model to predict male mortality for 65-80'; | |
run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment