[R] Help with using unpenalised te smooth in negative binomial mgcv gam

alice.jones alice.jones at noc.soton.ac.uk
Tue Jul 23 17:02:41 CEST 2013


Hi, 

I have been trying to fit an un-penalised gam in mgcv (in order to get more
reliable p-values for hypothesis testing), but I am struggling to get the
model to fit sucessfully when I add in a te() interaction.  The model I am
trying to fit is:
        gam(count~ s(x1, bs = "ts", k = 4, fx = TRUE) + 
        s(x2, bs = "ts", k = 4, fx = TRUE) + 
        te(x2, x3, bs = c("ts", "cc"), fx = TRUE) + 
        log(offset(y)), 
        knots = list(x3=c(0,360)), family = negbin(c(1,10)))

The error message I get is:
"Error in sm[[i]]$S[[j]] : attempt to select less than one element"

I can fit this model sucessfully if I don't specify the 'fx=TRUE' argument
(i.e. I can sucesfully fit the penalised model).  It also works when I only
include the two main terms x1 and x2, but do specify fx = TRUE, and it works
fine when I only specify the main term x1 and the te smooth for x2 and x3
and specify fx = TRUE (i.e. without a spearate specification of the main
term, x2, that is also included in the interaction).  But.... when I have
both main terms x1 and x2, as well as an interaction between x2 and x3,
without penalisation, I get the error.

I have played around with other data and with different covariate
specification, but it seems that any time I specify a main term that is also
included in the te interaction, within an un-penalised model, I get this
same error message.

Any help would be much appreciated, as I am trying to compare nested models
(i.e. the full model with the interaction term against the model that just
contains the two main terms).  I understand that the most appropriate way to
do this is to use an un-penalised model for p-value estimation.

Thanks, 

Alice





--
View this message in context: http://r.789695.n4.nabble.com/Help-with-using-unpenalised-te-smooth-in-negative-binomial-mgcv-gam-tp4672141.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list