mfasiolo / qgam

Additive quantile regression R package
http://mfasiolo.github.io/qgam/
30 stars 7 forks source link

Error for small datasets - A term has fewer unique covariate combinations than specified maximum degrees of freedom #35

Closed florianhartig closed 4 years ago

florianhartig commented 4 years ago

Hi Matteo,

in DHARMa, for small datasets, I have the problem that qgam may fail with

Error in smooth.construct.tp.smooth.spec(object, dk$data, dk$knots) : A term has fewer unique covariate combinations than specified maximum degrees of freedom

I realize that this goes back to mgcv, but in any case I was wondering: is there anything smarter one could do about this than just trying to catch the error?

Why does mgcv not fall back on a simpler spline automatically if there are not enough data points? I believe that, from a user viewpoint, it would be preferable that mgcv fits a simple line for small data, over getting an error.

Cheers, Florian

mfasiolo commented 4 years ago

Hi Florian,

Yes, this error comes from mgcv. It might be preferable to handle it in smooth.construct.tp.smooth.spec itself, as I think you are suggesting. I don't think it makes sense trying to handle it in qgam, because qgam would have to work out what effect is triggering the error, which would complicate the code.

Best, Matteo

florianhartig commented 4 years ago

Hi Matteo,

yes, I understand. I think I'll forward this to Simon, but if you see him, maybe you could also ask him about this.

Cheers, Florian