I work on an analysis of agreement between two independent measurements from the same subjects (errors-variables-model, Demming regression). I want show the deviations from the identity line (Y1=Y2) as needles perpendicular to the 45 degree line. I cannot use the standard error bars option in SGPLOT.
If (x, y) is one of your data points, you can use calculus to show that the perpendicular distance to the identity line is the point
( (x+y)/2, (x+y)/2). So just write a DATA step and use the VECTR statement:
data Have;
input x y;
datalines;
1 2
3 5
2 3
2 1
4 5
5 3
3 4
4 4
4 .
;
data Want;
set Have;
x1 = (x + y)/2;
run;
proc sgplot data=Want aspectratio=1;
scatter x=x y=y;
vector x=x y=y / xorigin=x1 yorigin=x1 noarrowheads;
lineparm x=0 y=0 slope=1;
run;
Since you didn't really tell us how you did the Deming regression, I will have to assume that you have the original data point, and the orthogonal projection onto the regression line.
If you have these, then you can use the SG annotation feature that works with PROC SGPLOT, specifically the LINE function or the %SGLINE macro. A brief example is here: https://documentation.sas.com/?docsetId=grstatproc&docsetTarget=n0eben23mwnl3dn1cm95zbks0eea.htm&doc...
Okay, but ... do you have the values of the perpendicular projections onto the line?
If (x, y) is one of your data points, you can use calculus to show that the perpendicular distance to the identity line is the point
( (x+y)/2, (x+y)/2). So just write a DATA step and use the VECTR statement:
data Have;
input x y;
datalines;
1 2
3 5
2 3
2 1
4 5
5 3
3 4
4 4
4 .
;
data Want;
set Have;
x1 = (x + y)/2;
run;
proc sgplot data=Want aspectratio=1;
scatter x=x y=y;
vector x=x y=y / xorigin=x1 yorigin=x1 noarrowheads;
lineparm x=0 y=0 slope=1;
run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.