BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Levi_M
Fluorite | Level 6

Hi! I am putting together a segmented regression with visualization. However, plotting the data, I can not seem to get the two periods to touch. Could anyone help provide assistance with this?

 

unnamed.pngproc autoreg data=a1;              

      model rates = QTRs aft_cnt  / method=ml nlag=12 backstep dwprob loglikl;;

      output out=auto_reg predicted=pred;

      by Patient_Age_Category;                                                /*This line of code will treat each age_cat separately*/

quit;

 

proc sgplot data=glimmix_out noautolegend;

      block x=QTRs block=period / transparency=.75;

      scatter x=QTRs y=rates / markerattrs=(symbol=CircleFilled color=black);

      series x=QTRs y=pred / group=period lineattrs=(thickness=3);

      by Patient_Age_Category;                                                /*This line of code will treat each age_cat separately*/

run;

 

 

Thank you!!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

But your blue line and your red line do not intersect each other at the boundary between blue and red. They would intersect to the left of the boundary, in the blue region.

--
Paige Miller

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

I don't know what you mean by this: "I can not seem to get the two periods to touch" ?? What should the plot look like if the two periods touched? (It looks like they touch to me, separated by a vertical line)

--
Paige Miller
Levi_M
Fluorite | Level 6

Thank you for your reply. What I meant to say was the two regression lines. 

 

EDIT: for example, when I run this same process in R, the two regression lines meet at the joint. (with the same results)

PaigeMiller
Diamond | Level 26

But your blue line and your red line do not intersect each other at the boundary between blue and red. They would intersect to the left of the boundary, in the blue region.

--
Paige Miller
Levi_M
Fluorite | Level 6

I see what you are saying, thanks. I just need to drop that boundary region. 

 

Thanks.

svh
Lapis Lazuli | Level 10 svh
Lapis Lazuli | Level 10
My guess is that the regression line in the left panel is only extending across the range of the data in the "before" period. The point on the vertical line would seem to belong to the "after" period.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 868 views
  • 0 likes
  • 4 in conversation