BookmarkSubscribeRSS Feed
shahd
Quartz | Level 8

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

 

 

8 REPLIES 8
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
shahd
Quartz | Level 8

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;

PaigeMiller
Diamond | Level 26

Please take a look at the documentation for the SERIES command. It's not hard to figure out.

https://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=grstatproc&docsetTarget=n1jkq...

 

 

--
Paige Miller
mkeintz
PROC Star

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

  1. de-mean Y  (i.e. newY=  Y-mean(Y)), and

  2. de-mean X, and then multiply by the ratio of (coefficient of X for the normal regression) divided by (coefficient of X for the NOINT regression).   I.e.   NEWX =  [x- mean(x)] * ([Normal Coeff)/(Noint Coeff)], and

  3. Apply the REG statement to newy=newx.

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.

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
PGStats
Opal | Level 21

You can also get a decent plot by adding option plots=fitplot to the proc reg statement.

PG
PaigeMiller
Diamond | Level 26

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

 

Capture.PNG

 

 

 

 

--
Paige Miller
PGStats
Opal | Level 21

Indeed. Hence the importance of the fitplot. Smiley Happy

PG

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 14850 views
  • 7 likes
  • 5 in conversation