Data visualization with SAS programming

Regression Plot Matrix with insets

Reply
Occasional Contributor
Posts: 5

Regression Plot Matrix with insets

Hi,

I'm looking to create a scatter plot matrix with regression lines that also displays the r-squared and p value in an inset for each graph. I have tried using proc template with scatterplotmatrix, but I can only get a pearson correlation in the inset, and no regression line. I also tried proc sgscatter, but cannot get the inset to display the statistical information I need. Does anybody have any suggestions on how I can accomplish this?

Thanks

ods graphics on;

proc sgscatter data=work.query_for_stabsummarytablesfilte;

compare y=(FairnessIdxAvgTotal_Mean EqGiniVisibleTotal ) x=(GES1_SUM GES61_SUM COH4_SUM)

/ Legend=(Position=Bottom) reg=(clm nogroup) ;

Title "Group Variables";

label FairnessIdxAvgTotal_Mean="Group Fairness Idx"

  EqGiniVisibleTotal = "Equality Barrier Reveals"

   GES1_SUM = "GES:Unity"

   GES61_SUM = "GESSmiley Tongueroud"

   COH4_SUM = 'PCQ:Best Anywhere';

WHERE groupName = 'A' OR groupName = 'B' OR groupName = 'C' OR groupName = 'D' OR groupName = 'E';

run;

proc template;

define statgraph spminset;

begingraph;

entrytitle "Group TPT Metrics and Cohesion";

entrytitle 'Concordia 2013';

layout gridded;

scatterplotmatrix GES1_SUM GES61_SUM COH4_SUM/

  rowvars=(FairnessIdxAvgTotal_Mean EqGiniVisibleTotal)

  inset=(nobs pearson pearsonpval)

  insetopts=( border=true opaque = true)

  corropts=(nomiss=true vardef=df)

  markerattrs=(size=4px)

  ellipse=(alpha=.20 type=predicted);

endlayout;

endgraph;

end;

run;

proc sgrender data=work.query_for_stabsummarytablesfilte template=spminset;

WHERE groupName = 'A' OR groupName = 'B' OR groupName = 'C' OR groupName = 'D' OR groupName = 'E';

label FairnessIdxAvgTotal_Mean ="Group Fairness Idx"

   EqGiniVisibleTotal = "Equality Barrier Reveals"

   GES1_SUM = "GES:Unity"

   GES61_SUM = "GESSmiley Tongueroud"

   COH4_SUM = 'PCQ:Best Anywhere' ;

run;

ods graphics off;

Super User
Posts: 19,007

Re: Regression Plot Matrix with insets

Here's an example of the reg line using sgscatter, not sure about the inset part.

48465 - Use an attribute map with the SGSCATTER procedure

Occasional Contributor
Posts: 5

Re: Regression Plot Matrix with insets

yes, i was able to use SGSCATTER to create the graphs, however I'd like to have p-value and r-squared listed for each plot. It seems that SGSCATTER has no options for this.

Contributor
Posts: 24

Re: Regression Plot Matrix with insets

If the values are calculated outside, put them into macro variable and use a legend. Ive done similar for pvalues using the legend examples below

legenditem type=marker name="PValue" / LABEL="Log rank test: p=&PValue" lineattrs=GraphData1(color=black THICKNESS=10)

         labelattrs=(size=8 family="Arial") markerattrs=(size=0);

discretelegend "PValue" / titleattrs=(size=9 family="Arial")

                          BORDER=false across=1 location=inside

                          halign=left valign=bottom pad=(bottom=35);

SAS Super FREQ
Posts: 1,134

Re: Regression Plot Matrix with insets

For a small 3x3 with custom labels using GTL, you could build the matrix yourself.  That is what is happening in the background anyway.  Use a LAYOUT LATTICE with a 3x3 row-column layout, and insert the necessary scatter, reg and insets into the cells yourself.  Quite doable, especially for a small matrix.

If you want ROWVARS, you can create the appropriate combinations.  The general idea is shown in this article, but you can see what needs to be done and customize to your needs.  Compact Scatter Plot Matrix - Graphically Speaking

Ask a Question
Discussion stats
  • 4 replies
  • 600 views
  • 0 likes
  • 4 in conversation