Hi all,
I need to run the regression without the intercept.
so I wrote this code:
proc reg data= calibration;
model y =x1/noint;
How can i change the cordinate values for the resulted model.
I used this code but still give me the model with the intercept :
proc sgplot data=calibration;
reg x=x1 y=y/ CLM CLI;
title 'Regression analysis for group "G"';
xaxis values=(0,0.1,0.2,0.3,0.4,0.5,0.6);
yaxis values=(0,0.1,0.2,0.3,0.4,0.5,0.6);
run;
could you please advise with this
There's no option in SGPLOT to plot a regression with no intercept.
You would have to output the predicted values from PROC REG, and then in PROC SGPLOT connect them with the SERIES command. You could also add the SCATTER command to the same PROC SGPLOT if you wnat to show the line and the data on the same plot.
This is very helpful! Could you please guide me through these steps, I modified the code according to the following:
proc reg data= calibration;
model y =x1/noint;
run;
output p=y;
proc sgplot data=p;
series x,p;
title 'Regression analysis for group "G"';
xaxis values=(0,0.1,0.2,0.3,0.4,0.5,0.6);
yaxis values=(0,0.1,0.2,0.3,0.4,0.5,0.6);
run;
Please take a look at the documentation for the SERIES command. It's not hard to figure out.
I don't think the REG statement in proc sgplot offers an analog to NOINT.
So I agree you have to manipulate the values. You can
I believe the CLM CLI limits are consistent over linear transformations, so this plot should be what you expect. The REG statement will still generate an intercept, but it will be very close to zero, showing no effect on your plot. Multiplying the de-meaned X value by the coefficient ratio reproduces the slope generated in proc reg with the NOINT option. I suppose there are options in SGPLOT to post original values for tick marks corresponding to the new values used for plotting.
You can also get a decent plot by adding option plots=fitplot to the proc reg statement.
Thanks for the reminder, @PGStats . As an old-timer, who began when SAS had only PROC GPLOT and PROC GCHART to produce graphics, sometimes I forget that ODS graphics usually has what you want all programmed in, and then there's no need to try to get SGPLOT to produce the graphic.
One thing that bugs me when someone wants to fit a model with no intercept is that this model rarely fits well. Of course, there are cases where it fits well, but usually it doesn't. The logic that if x is zero, then y must be zero, hence we don't need an intercept is usually terribly flawed. For example, in SASHELP.CLASS, you could use that logic, if weight=0 then height must be zero, hence we don't need an intercept, produces a very poor fit. I understand this is a trivial example, and real-life may be more complicated, but I rarely run across examples where NOINT is the right thing to do.
ods graphics on;
proc reg data=sashelp.class plots=fitplot;
model height=weight/noint;
run;
quit;
Produces this plot, and you can see that the fitted line with NOINT really doesn't fit the data well
Indeed. Hence the importance of the fitplot.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.