Skip to content
Prev 316398 / 398503 Next

Why are the number of coefficients varying? [mgcv][gam]

Andrew,

I think that the weird edfs may result from an unhandled case in the 
side constraint calculation. In particular the term

s(BCAR.imp,bs="cr",k=length(BCAR.knots),by=as.factor(pot.trial))

is confounded with

te(soc.imp,BCAR.imp,k=c(4,4))

but there was an issue with picking this up properly because of the factor 'by' variable, which should have been fixed by a change in 1.7-13. If it wasn't picked up then the fitting routines would have noticed a lack of identifiability later, and dealt with it - which is how the terms can then end up having no degrees of freedom (instead of the 1 EDF that would be expected for fully penalized).

In itself this would not explain the difference in number of coefficients, however. The obvious options there are that some factor levels have got dropped for some replicates, or that for some replicates some smooth arguments do not have enough unique values to allow  the number of knots specified, in which case the number of knots will be reduced. The only way to get further, I think, is to to compare coef(mod) for a couple of models that differ in their number of coefficients, and find the labels of the coefficients that have been dropped....

best,
Simon
On 29/01/13 00:20, Andrew Crane-Droesch wrote: