Regression – Can Daily Count Data Use GAM Ordered Categorical Family?

gamlssgeneralized-additive-modelmgcvnonparametricregression

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
enter image description here
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?

Best Answer

For smoothing functions in gamlss I usually use
P-splines, e.g.
pb(Time),
where the smoothing parameter is estimated automatically using a local maximum likelihood estimation.

Alternatively a local GAIC can be used, e.g.
pb(Time, method="GAIC", k= 4),
for a Generalised AIC, with penalty 4 for each degree of freedom used.

Alternatively a local GCV can be used, e.g. pb(Time, method="GCV").

Alternatively the user can fix the degrees of freedom, e.g.
pb(Time, df=5).

However to use an explanatory variable, the data would need to be individual cases, e.g. (count of hospital admissions, Time), not frequency data as you give above.