BookmarkSubscribeRSS Feed
psh23
Fluorite | Level 6

I am trying to fit a DLNM using GAM in SAS. I am getting errors with my outcome variable, which is binary 0/1, I have tried with both character and numeric, and with and without reference value.

 

ERROR: The response variable ptb_recode has 1 level(s). A binary response must have two levels.

 


proc gam data=test1;
class ptb_recode;
model ptb_recode = loess(meanpm25_wk)
loess(lag1)
loess(lag2)
loess(lag3)
loess(lag4)
loess(lag5)
loess(lag6)
loess(lag7)
loess(lag8)
loess(lag9)
loess(lag10)
loess(lag11)
loess(lag12)
loess(lag13)
loess(lag14)
loess(lag15)
loess(lag16)
loess(lag17)
loess(lag18)
loess(lag19)
loess(lag20)
loess(lag21)
loess(lag22)
loess(lag23)
loess(lag24)
loess(lag25)
loess(lag26)
loess(lag27)
loess(lag28)
loess(lag29)
loess(lag30)
loess(lag31)
loess(lag32)
loess(lag33)
loess(lag34)
loess(lag35)
loess(lag36)
/ dist=binomial ;

run;

 

Thanks!!

6 REPLIES 6
Reeza
Super User

Can you show the output of a PROC FREQ on this variable:  ptb_recode ?

 

proc freq data=test1;
table  ptb_recode ;
run;
psh23
Fluorite | Level 6
ptb_recodeFrequencyPercentCumulativeCumulative
FrequencyPercent
021657589.3821657589.38
12574010.62242315100
Reeza
Super User

Do you have missing values in the other variables? To get that error for some reason SAS is including only observations of a single level which usually occurs if you have missing data for some reason?

 

Otherwise I think we'll need data to replicate the issue.

WarrenKuhfeld
Rhodochrosite | Level 12

@Reeza gave you the information that you need to answer your question.  I can't help but point out that you don't have to type that much syntax to create your model statement.  A simple ad hoc macro can easily do it, particularly when your variables are numbered lists like you have.

data x;
   input y x1-x10 @@;
   datalines;
1 2 3 3 8 8 5 10 7 5 8 1 5 4 8 10 9 8 10 2 1 5 1 5 8 9 5 10 9 8 7 6 2 1
6 6 3 5 9 6 6 6 8 10 1 7 7 7 8 10 3 3 4 1 10 1 7 9 9 9 9 7 1 9 3 8 1 9 7
10 9 7 8 2 7 2 1 1 10 1 3 10 4 9 2 4 4 6 1 10 5 9 8 7 10 6 1 9 5 1 10 10
8 9 10 5 4 8 8 3 2 2 2 7 2 9 10 2 8 10 2 2 3 8 7 7 4 8 9 1 8 8 2 6 1 1 6
10 10 7 2 2 8 2 6 5 10 2 8 9 4 9 1 7 2 7 5 5 6 4 6 10 8 6 1 2 8 8 1 8 9
1 4 5 4 1 2 8 10 9 2 5 3 10 6 2 6 2 9 10 2 6 9 9 3 1 5 9 2 10 3 10 7 9 3
7 10 6 4 2 10 9 1 2 6 8 8 3 5 10
;

proc gam;
   class y;
   model y = %macro l; %do i = 1 %to 10; loess(x&i) %end; %mend; %l;
run;
Rick_SAS
SAS Super FREQ

I would not use PROC GAM to analyze 242,000 observations and 37 variables. I suggest you switch to PROC GAMPL, which is much faster. You can use univariate splines instead of loess to model the nonlinearities. For an example and references, see "Nonparametric regression for binary response data in SAS."

Ksharp
Super User

I agreed with Rick. 242,000 observations  is too much for  PROC GAM to analyze.

PROC GAM required the expanse system resource to run Non parameter regression.

If you want fit non-linear effect, why not try  decision tree PROC HPSPLIT ?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 6 replies
  • 1627 views
  • 3 likes
  • 5 in conversation