I am fitting the following:
rma.glmulti.ran <- function (formula, data, random, ...) {
rma.mv(as.formula(paste(deparse(formula))), Variance, random= ~1 | Experiment, data = msa, method="REML", ...)
}
msa_res <- glmulti(MSA ~ MAPl+MAT_e+Duration.yrl+Fert+Naddl+Ndepl,
data=msa,
level=2,
exclude=c("MAPl:MAT_e","MAPl:Duration.yrl","MAPl:Fert",
"MAPl:Naddl","MAPl:Ndepl","MAT_e:Duration.yrl","MAT_e:Fert","MAT_e:depl",
"Duration.yrl:Fert","Duration.yrl:Ndepl","Duration.yrl:Naddl","Fert:Ndepl","Naddl:Ndepl"),
fitfunction=rma.glmulti.ran, crit="aicc")
The aim of this code is to include only these two interactions: "Naddl:MAT_e" and "Naddl:Fert". Thus, I am using exclude=c()
to filter out all the other undesirable pairwise interactions from the full model (level=2
).
This, theoretically should be the same than:
MSA ~ MAPl + MAT_e + ... + Naddl:MAT_e + Naddl:Fert
However I get this error when I add exclude=c()
in the formula:
Error in glmulti(MSA ~ MAPl + MAT_e + Duration.yrl + Fert + Naddl + Ndepl, :
Improper call of glmulti.
Am I missing something about exclude=c()
? Is there a more elegant way to specify interactions terms in 'glmulti'?
Couldn't find the data you were referring to, so i generated fictitious variables below;
The exclude didn't work for me too, so i hard coded the exclusion into the formula. The following code worked for me, and no undesired interactions went into the glmulti.