BookmarkSubscribeRSS Feed
panthibabu44
Calcite | Level 5

RegressionRegression

Hello everyone,

 

I am trying to fit categorical data to a continuous variable. The attached figure is a group of linear regression lines I created by putting both variables as continuous and grouped by another variable 'time'. My data is unbalanced, variable 'time' has unequal observations. 

I need help in obtaining regression equation (polynomial or quadratic?)  (y var to x var) for each 'time' variable but fitted with the best distribution.

/*this is the code I used to fit my data and produce those figures*/

proc glimmix data=reg;
by time;
class block plot;
model Y=X / htype=3 solution cl;* dist=binomial link=logit;
random block;
random _residual_/ subject=plot type=cs;
run;


/*but I think 'by time' statement is not accurate, 
so I tried doing this way, but do not know
how to extract regression equation for each 'time' from solution*/ proc glimmix data=reg; class block plot time; model Y=X|time / htype=3 solution cl;* dist=binomial link=logit; random block; random _residual_/ subject=plot type=cs; run; /* when trying with multinomial distribution and using method=quad,
because my data is unbalanced, I am getting this error "Estimation by quadrature is available only if the data can be processed by subjects.
Make sure that all G-side RANDOM statements have SUBJECT= effects.
If there are multiple SUBJECT= effects they need to form a containment hierarchy, e.g., SUBJECT=A, SUBJECT=A*B, SUBJECT=A(B), ... ."*/

I would appreciate any help.

 

Thanks,

Babu

1 REPLY 1
Reeza
Super User
It doesn't seem like you have enough data points to split your regression like that, based on the number of points in each graph. You appear to have less than 10 points per time period. The typical rule of thumb is 25 data points per variable so I wouldn't be testing a ton of models here either. They all appear linear so I'm not sure if there's even any value in testing the quadratic but its easy enough to do in your model statement.

Add a By statement to your desired regression procedure, for this, PROC REG or GLM may be fine, you don't have enough data for anything more complex.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 394 views
  • 0 likes
  • 2 in conversation