Reputation: 57
I am using SAS's adaptivereg procedure to create a piece-wise linear function with temperature (temp) as my x variable and Usage (usage_value) as my y variable. I can use the details of adaptivereg procedure to find the ranges of the different linear functions of the piece-wise function. Is there a way I can limit the number of ranges, (i.e. instead of having 8 linear functions in the piece-wise function, I want to limit it to 5 linear functions). Are there any options I can add that would let me limit the amount of linear functions?
Below is the code I am using. Where a1 is the name of my data set, temp is the independent variable, and usage_value is the dependent variable.
proc adaptivereg data=a1 plots=all details=bases;
model usage_value = temp;
run;
Upvotes: 0
Views: 348
Reputation: 12849
I love adaptivereg. It's such a cool little procedure.
You can use the df
option in the model
statement to control the total number of knots to consider, and the maxbasis
option to control the maximum number of knots in the final model. The higher the degrees of freedom that you use, the fewer the knots.
proc adaptivereg data=sashelp.air;
model air = date / df=12 maxbasis=3;
run;
You can also use the alpha=
option to fine-tune it. Increasing alpha will result in more knots.
An alternative approach can be using the pbspline
/spline
options in transreg
or proc quantreg
, respectively.
proc transreg data=sashelp.air;
model identity(air) = pbspline(date / evenly=6);
run;
proc quantreg data=sashelp.air;
effect sp = spline(date / knotmethod=equal(12) );
model air = sp / quantile=0.5;
run;
Upvotes: 1