2
$\begingroup$

I want to fit a GAM in R. My data are negative binomial. Plus they have a temporal autocorrelation.

m1 <- gam(Y~s(X,Day), s(fDate, bs="re"), family=negbin(c(1,10), link = log), data=data)  
Resid <- resid(m1)   
acf(Resid)

With the acf() function I have detected a temporal autocorrelation. Can I apply a correlation structure in gam(), or do I have to use gamm(), since in gamm() I can´t use a negative binomial function, or am I doing something wrong with that? Is it basically possible to apply a negative binomial family in gamm() like this?

m2 <- gamm(Y~s(X,Day), random=list(Date=~1), family=negbin(c(1,10), link = log),
 correlation=corAR1(form=~Day), data=data)
$\endgroup$
1
  • $\begingroup$ I think this should stay as on topic here. There are statistical issues with estimating auto-regressive components in generalized linear models - i.e. with an exponential link function if the AR term is positive it implies a non-stationary time series. (Although I am not that familiar with gamm - so I am not sure what form=~Day means exactly in this context.) So I think it should stay here, with a discussion of possible reasonable model specifications. $\endgroup$
    – Andy W
    Jun 18, 2014 at 12:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.