I would like to do a meta-model using data from different experiments with different blocking structures. For this, I would need to specify the different blocking structure (random effects structure) for the data from each experiment within the same model. Genstat has a function called vrmeta
that does this (see here for more info) but I prefer to work in R, and I can't figure out how to do it in R.
For example, one experiment has blocks and main plots, while another has blocks, main plots and split plots. I have tried giving each experiment unique columns for its blocks and plots, and then coding the model as:
model <- lmer(response<-treatment1*treatment2*exp+
(1|EXP1block/EXP1main)+
(1|EXP2block/EXP2main/EXP2split),
data=df)
This does not work and I get:
Error: Invalid grouping factor specification, EXP1main:EXP1block
... presumably because all data for EXP2 has NA values in EXP1main and EXP1block (and vice versa).
It would be great if someone could explain how specifying different structures could be achieved. I am currently using package lme4
but if this is easier in a different package please let me know.
Here is a dput of some fake data as a reproducible example if needed:
df<-structure(list(exp = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("EXP1", "EXP2"
), class = "factor"), treatment1 = structure(c(2L, 2L, 1L, 1L,
2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L), .Label = c("N",
"Y"), class = "factor"), treatment2 = c(40L, 60L, 40L, 60L, 40L,
60L, 40L, 60L, 40L, 60L, 40L, 60L, 40L, 60L, 40L, 60L), response = c(780L,
786L, 784L, 778L, 869L, 844L, 734L, 784L, 963L, 715L, 591L, 703L,
925L, 720L, 642L, 678L), EXP1block = structure(c(1L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, NA, NA, NA, NA, NA, NA, NA, NA), .Label = c("A",
"B"), class = "factor"), EXP1main = c(1L, 2L, 3L, 4L, 1L, 2L,
3L, 4L, NA, NA, NA, NA, NA, NA, NA, NA), EXP2block = structure(c(NA,
NA, NA, NA, NA, NA, NA, NA, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("A",
"B"), class = "factor"), EXP2main = c(NA, NA, NA, NA, NA, NA,
NA, NA, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L), EXP2split = structure(c(NA,
NA, NA, NA, NA, NA, NA, NA, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("a",
"b"), class = "factor")), class = "data.frame", row.names = c(NA,
-16L))