Hello,
I am trying to fit some variables through regression (temperatures (X&Y) and plots with various vegetation types, groups), but I want my output to look like the graph attached from Beeles et al., 2021, particularly the fit relative to the line 1:1 line. The code I am using is:
proc transreg data=work.import ss2 plots=fit(nocli noclm);
ods output coef=coef;
model identity(Y)=class(Forest_Type / zero=none) | identity(X);
run;
Thank you so much!
What about this code is not working for you?
data test;
input Forest_Type $ X Y;
datalines;
CO 16.8 16.8
CO 16 16.5
CO 16.5 16.9
CO 17 17.5
CO 18.2 18.2
CO 17.8 17.9
OP 17.9 18.1
OP 17.9 16.7
OP 13.9 14.9
OP 16.7 16.2
OP 17.8 17.8
OP 17 17.9
OP 17.2 16.8
OP 17.5 17.2
OP 17.9 16.7
PO 15.9 15.8
PO 14.4 13.4
PO 17.6 17.6
PO 15.2 15.8
PO 15.8 19.3
PO 16 16
PO 16.1 16
PP 16.4 15.6
PP 16.4 17.1
PP 16.9 16.6
PP 15.2 15.9
PP 16.6 16.4
SO 13.8 14.4
SO 14.9 14.6
SO 15.9 15.6
SO 15.8 19
;
run;
proc sgplot data=test;
scatter x=x y=y / group=forest_type;
reg x=x y=y / degree=1;
reg x=x y=y / degree=2;
lineparm x=0 y=0 slope=1 / clip;
run;
Here is the graph produced by this code:
proc sgplot data=have;
reg y=y x=x/degree=1;
reg y=y x=x/degree=2;
lineparm x=0 y=0 slope=1;
scatter y=y x=x/markerattrs=(symbol=circle) group=forest_type;
run;
Thank you PaigeMiller.
I tried your code but it is not working 😞
The resulting graph is this:
This is the data I am working with. Thanks for your insights.
Forest_Type | X | Y |
CO | 16.8 | 16.8 |
CO | 16 | 16.5 |
CO | 16.5 | 16.9 |
CO | 17 | 17.5 |
CO | 18.2 | 18.2 |
CO | 17.8 | 17.9 |
OP | 17.9 | 18.1 |
OP | 17.9 | 16.7 |
OP | 13.9 | 14.9 |
OP | 16.7 | 16.2 |
OP | 17.8 | 17.8 |
OP | 17 | 17.9 |
OP | 17.2 | 16.8 |
OP | 17.5 | 17.2 |
OP | 17.9 | 16.7 |
PO | 15.9 | 15.8 |
PO | 14.4 | 13.4 |
PO | 17.6 | 17.6 |
PO | 15.2 | 15.8 |
PO | 15.8 | 19.3 |
PO | 16 | 16 |
PO | 16.1 | 16 |
PP | 16.4 | 15.6 |
PP | 16.4 | 17.1 |
PP | 16.9 | 16.6 |
PP | 15.2 | 15.9 |
PP | 16.6 | 16.4 |
SO | 13.8 | 14.4 |
SO | 14.9 | 14.6 |
SO | 15.9 | 15.6 |
SO | 15.8 | 19 |
The lineparm x=0 y=0 slope=1; statement is the culprit. Since the picture of your data looked like it went to the origin, that is the way @PaigeMiller coded it. Your actual data has minimums around 13.4 and 13.8 so, change that lineparm line to
lineparm x=13 y=13 slope=1;
or something similar to that. Just specify your minimum value for the x and y axes. Actually, the axes will default to the data as long as you enter values on the lineparm line that are within the data range.
@Joa14 wrote:
Thank you PaigeMiller.
I tried your code but it is not working 😞
The resulting graph is this:
What about this is not working? You should explain instead of simply saying "not working" and providing no additional explanation. The plots looks to me to be correct.
The modification is even easier than Dan's suggestion: Just add the CLIP option to the LINEPARM statement:
lineparm x=0 y=0 slope=1 / clip;
What about this code is not working for you?
data test;
input Forest_Type $ X Y;
datalines;
CO 16.8 16.8
CO 16 16.5
CO 16.5 16.9
CO 17 17.5
CO 18.2 18.2
CO 17.8 17.9
OP 17.9 18.1
OP 17.9 16.7
OP 13.9 14.9
OP 16.7 16.2
OP 17.8 17.8
OP 17 17.9
OP 17.2 16.8
OP 17.5 17.2
OP 17.9 16.7
PO 15.9 15.8
PO 14.4 13.4
PO 17.6 17.6
PO 15.2 15.8
PO 15.8 19.3
PO 16 16
PO 16.1 16
PP 16.4 15.6
PP 16.4 17.1
PP 16.9 16.6
PP 15.2 15.9
PP 16.6 16.4
SO 13.8 14.4
SO 14.9 14.6
SO 15.9 15.6
SO 15.8 19
;
run;
proc sgplot data=test;
scatter x=x y=y / group=forest_type;
reg x=x y=y / degree=1;
reg x=x y=y / degree=2;
lineparm x=0 y=0 slope=1 / clip;
run;
Here is the graph produced by this code:
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 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.