BookmarkSubscribeRSS Feed
johnrizk
Calcite | Level 5

Hi all,

Figure 1 is for a study period Jan 2018 - Dec 2019.

 

(note: figure removed by request of author)

 

Figure 2 is for study period Jan 2017 - Mar 2020. 

 

(note: figure removed by request of author)

 

The values from Jan 2018 to Dec 2019 are the same for both figures, figure 2 is just an expanded version and includes more months. 

My question is - why does the band for predicted series values changes when we expand the period? Shouldnt the bands be the same given that same datapoints where used? THANK YOU!

 

CODE FOR BOTH FIGS:

 
/***************** Autoreg **********************/
ods output ParameterEstimates=parms;
PROC AUTOREG DATA = import_x;
MODEL rate = slope2 step ramp
/PLOTS=ALL METHOD=ML NLAG=12 DWPROB BACKSTEP;
OUTPUT OUT=outputdata PM=trendhat LCLM=lclm UCLM=uclm P=yhat LCL=lcl UCL=ucl;
/*PM= predicted values from only the structural part of the model;
useful in predicting the trend */;
/*P= predicted values from both the structural and autoregressive parts of the model;
useful in predicting future values of the current response time series */;
RUN;
 

PROC SGPLOT DATA=outputdata;

title 'Cephalosporins (non-targeted population)';

 

    SCATTER X=month Y=rate / MARKERATTRS = (COLOR=BLACK) 

 

                                LEGENDLABEL = "Observed values";

 

/* SERIES X=month Y=yhat / LINEATTRS =(COLOR=DABGR PATTERN=SHORTDASH)   */

/*  */

/*                                 LEGENDLABEL = "Predicted series values";  */

/*  */

 BAND X=month UPPER=ucl LOWER=lcl / FILLATTRS=(COLOR=LTGREY TRANSPARENCY=.7)  

/*  */

                                 LEGENDLABEL = "Band for predicted series values";

 

                SERIES X=month Y=trendhat / LINEATTRS =(COLOR= BLACK PATTERN=SOLID) 

 

                                LEGENDLABEL = "Predicted mean (trend)";

 

/*    BAND X=month UPPER=uclm LOWER=lclm /   */

/*  */

/* FILLATTRS= (COLOR= MEGR TRANSPARENCY=.5)   */

/*  */

/*                                 LEGENDLABEL = "Band for predicted trend";  */

 

                LABEL    Rate = "Prescription rate per 1,000 beneficiaries" 

 

                                                month ="Month";

 

   REFLINE '1dec2018'd / AXIS = X LINEATTRS =(PATTERN=SHORTDASH COLOR=BLACK);

   REFLINE '1dec2018'd / AXIS = X LINEATTRS =(PATTERN=SHORTDASH COLOR=BLACK);

  refline '1dec2018'd / axis= X

          lineattrs=(thickness=10 color=grey) transparency=0.6 ;

 

 

RUN;

 

ODS GRAPHICS OFF;

3 REPLIES 3
Rick_SAS
SAS Super FREQ

It's not PROC SGPLOT that is responsible for the difference in the predicted values, it is your regression model. The second model has an addition 12 observations before (and 3 after) the original observations. These observations cause the regression to choose a different model for the second set of observations. (Compare the parameter estimates for both models!) The graph is simply showing you the model in both cases, and they are different models.

johnrizk
Calcite | Level 5

This is very helpful! Thank you. I used PROC AUTOREG and I agree with you that the parameter estimates changes - this is probably because PROC AUTOREG makes adjustments based on autocorrelations (the second dataset expands 12 mo and 3 mo pre and post, respectively). Is it OK to present both figures in a manuscript or is it methodologically incorrect? Will it raise questions/concerns of why the confidence intervals are different?

Rick_SAS
SAS Super FREQ

Ultimately, the editor and reviewers will help you decide if it is "okay" to show both graphs. Be sure to explain the model that each graph visualizes. Since they are different models, it shouldn't be surprising that the graphs are different.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1097 views
  • 4 likes
  • 2 in conversation