BookmarkSubscribeRSS Feed
hussier1
Fluorite | Level 6

I'm trying to create a segmented regression which is quadratic in both segments, with the location of the breakpoint as one of the optimizing variables. I don't want to impose the condition that the overall regression be continuous, which seems to be complicating my attempts at implementation. Below is my current attempt in optmodel. The value for "break" that is returned is zero, so it seems like the break variable is somehow being ignored, even though the log acknowledges that there are seven variables in this optimization problem. When I substitute a specific numerical value for break, the optimization seems to work, so it seems like I am able to compute a segmented quadratic regression with a pre-specified breakpoint, but I can't seem to make the breakpoint one of the optimizing variables.

 

proc optmodel;
set <num> CCSM4_185;
set <num> Time;
num y{Time};
read data single into Time=[Time] y=CCSM4_185; 
var intercept1;
var intercept2;
var alpha1;
var alpha2;
var beta1;
var beta2;
var break;
min Obj=sum{i in Time} (if i<break then
((y[i]-(intercept1+alpha1*i+alpha2*i*i))**2)
else
((y[i]-(intercept2+beta1*i+beta2*i*i))**2));
solve;
print intercept1 intercept2 alpha1 alpha2 beta1 beta2 break;
3 REPLIES 3
sbxkoenk
SAS Super FREQ

I have moved your question / topic to the appropriate board (mathematical optimization).

 

You can also consider PROC NLIN :

or PROC ADAPTIVEREG :

Koen

hussier1
Fluorite | Level 6

Thank you for the reply! I tried the PROC nlin approach from the first blog post previously, but I wasn't able to find a way to adapt it, since it seemed like that method relied on the fact that continuity/smoothness meant that the breakpoint could be defined as a function of parameters. I'm struggling to find a way for the breakpoint to be a completely free variable.

RobPratt
SAS Super FREQ

Can you please share your data set?

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!
Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 415 views
  • 2 likes
  • 3 in conversation