BookmarkSubscribeRSS Feed
WilliamBoecklen
Fluorite | Level 6

I am trying to run a quadratic regression in SAS Studio. I specify in the Model tab that I want a polynomial of degree 2. The output gives no parameter estimates for the squared term and the test of the model has only 1 degree of freedom.

screenshot-localhost-10080-2019.04.23-17-20-47.jpg

screenshot-localhost-10080-2019.04.23-17-26-21.jpg

If I specify a polynomial of degree 3, I get parameter estimates for the first and third degree terms but not for the second degree term.

 

If I use data transformation to create a squared variable, I can get a parameter estimate for the squared term in the regression.

10 REPLIES 10
WarrenKuhfeld
Rhodochrosite | Level 12

Assume that the software is correct, and plot your data to see why it is correct.

WilliamBoecklen
Fluorite | Level 6

Thanks for the response, bu I think there is something wrong with the program. The data are atmospheric CO2 levels measured at Mauna Loa each December from 1958 trough 2018 inclusive. If I do a simple linear of CO2 concentration versus year there is an obvious lack of fit.

screenshot-localhost-10080-2019.04.24-10-59-45.jpg

screenshot-localhost-10080-2019.04.24-11-01-57.jpg

If I use data transformation to create a new variable that is the square of year and I enter both in a regression on CO2 concentrations there is a significant improvement in fit.

 

screenshot-localhost-10080-2019.04.24-11-08-11.jpg

I get the following parameter estimates and test of model:

 

screenshot-localhost-10080-2019.04.24-11-09-45.jpg

screenshot-localhost-10080-2019.04.24-11-10-55.jpg

 

However, if I start only with Year and ask SAS to do a polynomial regression of degree 2, I get the following parameter estimates and test of model:

 

screenshot-localhost-10080-2019.04.24-11-14-02.jpg

screenshot-localhost-10080-2019.04.24-11-15-06.jpg

One could argue that the program simply did not include the years-squared term into the model, but the following plot suggests otherwise as there is improved fit when compared to the model with years alone.

 

screenshot-localhost-10080-2019.04.24-11-18-17.jpg

 

I suspect that there is faulty communication between proc glmselect and proc reg in SAS Studio.

WilliamBoecklen
Fluorite | Level 6

Is there a way to refer this problem to SAS technical support?

My students request an answer.

Thanks.

WarrenKuhfeld
Rhodochrosite | Level 12

My suggestion was to plot your data to see why SAS is producing correct results.

WilliamBoecklen
Fluorite | Level 6
SAS is NOT producing correct results. Besides, I have plotted the data and so have my students. Why do I get proper results when I "manually" build a model with X and X-squared, but not when I ask SAS (by way of a dialog box) to build a polynomial of degree 2?
WarrenKuhfeld
Rhodochrosite | Level 12

Post the plot.  I don't have your data, and I have retired, so I don't have SAS at the moment.  However, I can say with a great deal of confidence, after almost 35 years as a SAS/STAT developer including writing one of the regression procedures, SAS does not get problems like this wrong. Users, on the other hand, often do not understand least squares, floating point arithmetic, collinearity, sequential sweeps, sweeps with rational pivoting, type two tests, and so on, so. If I were a betting man, I would bet that SAS has it right, and the problems lie with your expectations. If you want to contact technical support, you can certainly do that, but SAS Communities questions are not routed to them.

BrianGaines
SAS Employee

@WarrenKuhfeld,

 

You may already know this, but now that you are retired you can download and use SAS University Edition for non-commercial purposes (https://www.sas.com/en_us/software/university-edition/download-software.html).  It include SAS/STAT 15.1.  

 

I hope you are enjoying your well-deserved retirement!

 

Best,

 

-Brian

WarrenKuhfeld
Rhodochrosite | Level 12
Brian, I do. Thanks! I just haven't needed to yet for anything, so I have
not done it,
BrianGaines
SAS Employee

@WilliamBoecklen,

 

Is the data set you are using publicly available, or would you be willing to share it?  If so I can take a closer look at it to see if I can figure out what is going on.  

 

Thanks,

 

-Brian

WilliamBoecklen
Fluorite | Level 6

For the sake of closure, I post the response I received from SAS technical support:

 

William,

 

As I suspected there is what we call "near" singularity in the data and model that tends to happen with polynomial models.  The condition number of X`X matrix is huge as shown in the following PROC IML program:

 

proc iml;

   use sasuser.co2;

   read all var {year};

   x = j(nrow(year),1) || year || year##2;

 

   print (max(eigval(x`*x))/min(eigval(x`*x)));

quit;

                                 3.1771E21

 

In this case GLM and REG algorithm handles this particular near singularity better than GLMSELECT.  The general recommendation is not use raw Year values in polynomial models; center and scale values of year first.  For example, I center the polynomial term and now I reproduce the same results as REG and GLM.

 

 

procmeansdata=sasuser.co2;

varyear;

run;

 

datanew; setsasuser.co2;

centeryr=year - 1988;

run;

 

procglmselectdata=new;

modelco2= year centeryr*centeryr/selection=none;

quit;

 

I hope the above information is helpful to you. Please let me know if you have further questions on this particular matter.

 

Thank you for using SAS and for your patience in my reply.

 

Kathleen Kiernan

Senior Principal Technical Support Statistician

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 1702 views
  • 2 likes
  • 3 in conversation