BookmarkSubscribeRSS Feed
AlexeyS
Pyrite | Level 9

I want to run linear regression, but I have to add the next restriction  : yhat>=0, i.e predicted variable have to be greater or equal to zero. I use proc reg. if I cannot use it, maybe SAS has another procedure that can do it.

Thank you

7 REPLIES 7
Rick_SAS
SAS Super FREQ

Please tell us more about your problem. In particular:

1. Is the response variable an inherently positive quantity such as a count, a volume, or a weight? If it is a count, you might consider using PROC GENMOD and Poisson regression.

2. Are all of the observed responses positive? If so, the predicted values will also be positive on the convex hull of the observations. For an example, see the article "Truncate response surfaces."

 

AlexeyS
Pyrite | Level 9

My predicted dependent variable should be greater or equal to zero. It's like volume. I use proc reg, and didn't find an option to restrict yhat be ge zero

PaigeMiller
Diamond | Level 26

@AlexeyS wrote:

My predicted dependent variable should be greater or equal to zero. It's like volume. I use proc reg, and didn't find an option to restrict yhat be ge zero


It seems to me that @Rick_SAS has already provided the solution. If it doesn't work in your case, please give specific and detailed information about why it doesn't work.

--
Paige Miller
plf515
Lapis Lazuli | Level 10

Why do you want to restrict the predicted values to positive numbers?

What is the nature of your dependent variable?

 

If the DV is a count, then there is PROC COUNTREG which lets you do Poisson regression or negative binomial regression (I have never had a case where the assumptions of Poisson are valid - they may exist, but it may be as unlikely as a cavalry officer getting kicked to death by his horse. COUNTREG offers other options too.

 

If the DV is bounded on both ends (not just the low end at 0) then beta regression could work (you may have to divide the DV by its max value).  You can do this in PROC GLIMMIX using the DIST = beta option on the model statement.

 

If neither of those are the case, you could try taking the log of the DV and then back transforming after the regression - but I don't necessarily recommend this.

 

 

AlexeyS
Pyrite | Level 9

My dependent variable is greater or equal to zero. I want that predicted DV will be the same. My variable looks like volume. I use proc reg but I saw that this procedure don't have an option to restrict predicted value of DV.

Rick_SAS
SAS Super FREQ

There is no way to restrict the predicted value in PROC REG. The predictions are determined by least squares regression.

 

If you are getting negative predicted values, then you need to examine other options. For example, the regression fit might be influenced by one or more outliers or high-leverage points that are pulling the regression line up or down. If so, you might try PROC ROBUSTREG for robust regression.

 

I also like Peter's suggestion. However, instead of performing an OLS fit of LOG(Y) and then taking EXP of the predicted values, you could use PROC GENMOD to fit a log-link model. For a discussion of the two models and why they are different, see "Error distributions and exponential regression models."

Ksharp
Super User

I am not sure, you could try other distribution and LINKED function.

 

proc genmod data=sashelp.class;
model weight=height/dist=gamma link=log;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

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.

Discussion stats
  • 7 replies
  • 1241 views
  • 4 likes
  • 5 in conversation