[datatable-help] Fitting interaction term in GAMM with random effect

SamLC slcox417 at gmail.com
Tue Apr 5 16:54:10 CEST 2016


Hi,

I am trying to fit a model with a random effect of DeploymentID with a
nested AR1 autoregressive correlation structure.  For the fixed component I
am fitting a smooth of tide.  I have two sets of models I am fitting with
different data sets.  For the smooth of tide, I want a separate smooth to be
fitted per SiteID.  In one set of models this is fine (each SiteID contains
multiple DeploymentIDs).  In the other SiteID and DeploymentID are
identical.  I am wondering how to code this.  I am not interested in the
intercept of SiteID hence why it has previously been a random effect.  I am
interested in how smooths vary between SiteIDs and hence why this is a fixed
effect.

Example data structure first data set:

SiteID    DeploymentID
1                  1
1                  1
1                  1
1                  1
1                  1
1                  2 
1                  2 
1                  2 
1                  3
2                  4 
2                  4
2                  4
2                  4
2                  4
2                  5
2                  5
2                  5
3                  6
3                  7
3                  8
etc etc

Example data structure seconddata set:

SiteID    DeploymentID
1                  1
2                  2
3                  3
4                  4

My problem is that I understand to fit a interaction term, one must use 
gamm(Y~s(tide,k=5,bs="cc",by=SiteID)+SiteID,knots=list(tide=c(0,1)),correlation=corAR1(form=~1|DeploymentID).....

- if I include +SiteID then I should NOT include DeploymentID as a random
effect also (for the second model where SiteId and DeploymentID are
identical - but this is ok for the first model)?
-the problem is when I want to compare nested models I run into issues if
the smooth term is dropped as I do not have a random or smooth term in the
model.

Can I code as
gamm(Y~s(tide,k=5,bs="cc",by=SiteID),knots=list(tide=c(0,1)),random=list(DeploymentID=~1),correlation=corAR1(form=~1|DeploymentID).....

Any help on this is appreciated....

Cheers





--
View this message in context: http://r.789695.n4.nabble.com/Fitting-interaction-term-in-GAMM-with-random-effect-tp4719322.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list