Hopefully this is a fairly basic question. I'm wondering if its possible in R-INLA to interact a fixed effect term with a structured random effect term.
My fixed effect term is simply an indicator variable, specifying the before and after period of a treatment policy. Lets call this treatment.
My structured random effect is time with a seasonal variation structure. Lets call this time.
Additionally, my model has an SPDE structured spatial random effect, which has an i.i.d. grouped structure. Therefore, all my data, along with covariates, is in an inla.stack object.
I want my formula to look something like what follows:
f ~ 0 + b0 + treatment : f(time, model = "seasonal", season.length = 12) + f(spatial.field, model = spde, group = spatial.field.group, control.group = list(model = 'iid'))
However, my INLA doesnt take this formula, outputting the following error:
Error in treatment:f(time, model = "seasonal", season.length = 12) :
In addition: Warning messages:
1: In treatment:f(time, model = "seasonal", season.length = 12) :
numerical expression has 169632 elements: only the first used
2: In treatment:f(time, model = "seasonal", season.length = 12) :
numerical expression has 50 elements: only the first used
If I change my formula to instead use treatment * f(time, model = "seasonal", season.length = 12), I get the following error:
Error in model.frame.default(new.fix.formula, data.same.len, na.action = inla.na.action) :
invalid type (list) for variable 'f(time, model = "seasonal", season.length = 12)'
In addition: Warning message:
In rt[i] <- ind :
number of items to replace is not a multiple of replacement length
I'm wondering if the issue is arising because what I am trying to do doesnt make too much sense to begin with or if its due to the structure of the inla.stack object and how the time random effect is being treated.
Thanks in advance,