The observed response variable Y takes on one of K(=21) ordered categories.
Here is a summary of my response data (count data: the number of hospital admission in each day), y has observations across all the levels The second line is about the number of the oservations that take the value of the first line.
I tried GAM with the following code
m<-gam(sum ~ s(Time,k=20)+s(RSK, k=10),data = mydata, method = "REML",family = ocat(R =21))
But I always get the following Error:
Error in eval(family$initialize) : Values out of range
I was confused about the count data in using ocat GAM ordered categorical family, any help would be much appreciated!
how to fix this problem?