[R] Multiple interaction terms in GAMM-model
Jeroen
jeroen.van.leuken at rivm.nl
Thu Jul 25 13:56:11 CEST 2013
Dear all,
I am trying to correlate a variable tau1 to a set of other variables (x1,
x2, x3, x4), taking into account an interaction with time ('doy') and place
('region'), and taking into account dependency of data in time per object
ID. My dataset looks like:
doy objectID region tau1 x1 x2
x3 x4
1 1 A 0.000000 0.08
0.3657 64.1 0.001100
1 2 C 0.000000 0.10
0.3150 74.3 0.000847
1 3 B 0.000000 0.07
0.3264 60.9 0.000854
1 4 B 0.000000 0.08
0.3058 63.2 0.000713
1 5 D 2.716998 0.11
0.2835 93.7 0.000660
....
365 1 A 0.010000 0.06
0.5489 27.3 0.003878
365 2 C 0.234000 0.12
0.1798 23.1 0.000278
365 3 B 1.353500 0.09
0.3417 37.8 0.000271
365 4 B 0.000000 0.40
0.1347 13.4 0.000173
365 5 D 3.478008 0.21
0.2384 37.7 0.000703
The total dataset consists of 151,840 rows (365 days x 416 object ID's)
Since the data is dependent in time per objectID, I use a GAMM model with an
autocorrelation function. Since each variable x1, x2, etc. is dependent on
time and place, I should incorporate this as well.
Therefore I am wondering if the following gamm-model is correct for my
situation:
model <- gamm( tau1 ~ te( x1, by= doy ) + te( x1, by= factor( region ) ) +
... + te( x4, by= doy ) + te( x4, by= factor( region ) ) + factor( region ),
correlation= corAR1(form= ~ doy|objectID ), na.action= na.omit ).
Does anyone know if this is ok?
Or should I use a model which also includes terms like " te( x1 ) + ... +
te( x4 )".
And is the correlation function correct?
Thanks so much!!
Jeroen
--
View this message in context: http://r.789695.n4.nabble.com/Multiple-interaction-terms-in-GAMM-model-tp4672297.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list