我正在使用glmer()
分析一些数据。我正在学习R和建模时,请多多包涵。
我的数据由两个预测变量Area
和Day_Night
组成,我用它们来解释Standing
,Feeding
或Foraging
中给定行为的发生
因为我有几个人的数据,所以我希望对为每个人选择的最佳模型取平均值,而该模型恰好具有与我已经计算过的AICc
值相同的累加效果。该模型是:
best_model_individual1<-glmer(cbind(Standing,Feeding_Foraging) ~ Day_Night + Area+(1|ID) , data=GLM_df , family=binomial)
但是,当平均每个人的最佳模型时,我得到了错误:
> models<- list(best_model_individual1,best_model_individual2,best_model_individual3)
> averages<-model.avg(models, beta = c("none"),
+ rank = NULL, rank.args = NULL, revised.var = TRUE,
+ dispersion = NULL, ct.args = NULL)
Error in model.avg.default(models, beta = c("none"), rank = NULL, rank.args = NULL, :
models are not all fitted to the same data
我不确定这是否是由于我的函数参数可能存在错误,还是因为无法通过统计得出此类平均值。
我希望有人可以推动我!任何输入表示赞赏。
我正在为以下单个1提供dput()
模型中使用的数据样本:
> dput(GLM_df)
structure(list(V1 = 1:144, hour = c(0L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L,
0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L),
Feeding = c(4L, 3L, 2L, 7L, 8L, 7L, 7L, 7L, 6L, 7L, 8L, 7L,
7L, 7L, 9L, 13L, 5L, 4L, 3L, 5L, 5L, 7L, 5L, 5L, 7L, 5L,
5L, 11L, 14L, 10L, 9L, 9L, 9L, 9L, 10L, 9L, 10L, 9L, 10L,
9L, 8L, 5L, 4L, 8L, 11L, 11L, 11L, 9L, 6L, 3L, 3L, 8L, 11L,
11L, 9L, 9L, 9L, 9L, 10L, 9L, 10L, 9L, 7L, 9L, 8L, 3L, 4L,
6L, 7L, 10L, 7L, 7L, 4L, 4L, 2L, 8L, 11L, 11L, 9L, 10L, 9L,
8L, 8L, 7L, 6L, 6L, 5L, 2L, 4L, 3L, 3L, 4L, 4L, 6L, 7L, 6L,
4L, 4L, 3L, 6L, 7L, 6L, 5L, 6L, 5L, 4L, 4L, 5L, 4L, 3L, 3L,
2L, 4L, 3L, 3L, 4L, 4L, 4L, 5L, 4L, 7L, 3L, 4L, 6L, 5L, 6L,
7L, 9L, 8L, 8L, 10L, 10L, 10L, 8L, 6L, 5L, 8L, 5L, 3L, 6L,
6L, 7L, 6L, 6L), Foraging = c(23L, 24L, 24L, 19L, 18L, 20L,
18L, 19L, 19L, 17L, 16L, 17L, 17L, 17L, 14L, 10L, 20L, 24L,
24L, 22L, 21L, 21L, 21L, 22L, 18L, 20L, 21L, 9L, 5L, 9L,
10L, 12L, 12L, 10L, 10L, 10L, 9L, 9L, 7L, 5L, 14L, 20L, 20L,
16L, 11L, 12L, 12L, 15L, 15L, 19L, 18L, 7L, 5L, 5L, 9L, 9L,
9L, 8L, 6L, 8L, 7L, 8L, 6L, 5L, 10L, 17L, 17L, 15L, 13L,
12L, 13L, 13L, 22L, 24L, 26L, 10L, 3L, 6L, 8L, 9L, 9L, 6L,
7L, 8L, 8L, 6L, 3L, 2L, 8L, 24L, 23L, 18L, 15L, 14L, 15L,
19L, 19L, 21L, 24L, 10L, 4L, 6L, 8L, 8L, 6L, 6L, 7L, 6L,
6L, 6L, 3L, 3L, 11L, 23L, 24L, 21L, 18L, 17L, 11L, 16L, 19L,
23L, 22L, 6L, 5L, 5L, 7L, 7L, 8L, 8L, 7L, 9L, 6L, 4L, 3L,
2L, 7L, 22L, 20L, 18L, 15L, 12L, 12L, 15L), Standing = c(1L,
1L, 2L, 4L, 4L, 2L, 5L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L,
2L, 1L, 1L, 2L, 1L, 2L, 3L, 2L, 2L, 2L, 1L, 6L, 7L, 7L, 6L,
5L, 5L, 6L, 4L, 6L, 6L, 8L, 9L, 12L, 3L, 2L, 2L, 3L, 4L,
5L, 3L, 4L, 4L, 4L, 4L, 8L, 9L, 8L, 5L, 6L, 6L, 5L, 8L, 7L,
7L, 6L, 10L, 12L, 6L, 3L, 3L, 4L, 5L, 5L, 5L, 5L, 6L, 5L,
3L, 12L, 16L, 14L, 12L, 11L, 13L, 15L, 15L, 15L, 16L, 18L,
23L, 28L, 17L, 5L, 5L, 9L, 12L, 12L, 13L, 8L, 9L, 5L, 4L,
13L, 19L, 19L, 17L, 17L, 19L, 20L, 20L, 19L, 20L, 22L, 24L,
28L, 15L, 5L, 4L, 7L, 12L, 10L, 14L, 11L, 7L, 8L, 5L, 19L,
23L, 20L, 16L, 13L, 14L, 14L, 13L, 13L, 13L, 18L, 21L, 24L,
16L, 6L, 8L, 9L, 12L, 14L, 13L, 11L), ID = c("41361", "41361",
"41361", "41361", "41361", "41361", "41361", "41361", "41361",
"41361", "41361", "41361", "41361", "41361", "41361", "41361",
"41361", "41361", "41361", "41361", "41361", "41361", "41361",
"41361", "41365", "41365", "41365", "41365", "41365", "41365",
"41365", "41365", "41365", "41365", "41365", "41365", "41365",
"41365", "41365", "41365", "41365", "41365", "41365", "41365",
"41365", "41365", "41365", "41365", "41366", "41366", "41366",
"41366", "41366", "41366", "41366", "41366", "41366", "41366",
"41366", "41366", "41366", "41366", "41366", "41366", "41366",
"41366", "41366", "41366", "41366", "41366", "41366", "41366",
"41366bis", "41366bis", "41366bis", "41366bis", "41366bis",
"41366bis", "41366bis", "41366bis", "41366bis", "41366bis",
"41366bis", "41366bis", "41366bis", "41366bis", "41366bis",
"41366bis", "41366bis", "41366bis", "41366bis", "41366bis",
"41366bis", "41366bis", "41366bis", "41366bis", "41367",
"41367", "41367", "41367", "41367", "41367", "41367", "41367",
"41367", "41367", "41367", "41367", "41367", "41367", "41367",
"41367", "41367", "41367", "41367", "41367", "41367", "41367",
"41367", "41367", "41368", "41368", "41368", "41368", "41368",
"41368", "41368", "41368", "41368", "41368", "41368", "41368",
"41368", "41368", "41368", "41368", "41368", "41368", "41368",
"41368", "41368", "41368", "41368", "41368"), Area = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Loliondo", "Seronera"
), class = "factor"), Feeding_Foraging = c(27L, 27L, 27L,
26L, 25L, 27L, 25L, 26L, 25L, 24L, 24L, 24L, 24L, 24L, 23L,
23L, 25L, 28L, 27L, 27L, 27L, 27L, 27L, 27L, 25L, 25L, 26L,
19L, 19L, 19L, 20L, 21L, 20L, 20L, 20L, 19L, 19L, 18L, 16L,
14L, 22L, 25L, 24L, 24L, 22L, 22L, 23L, 23L, 21L, 22L, 21L,
16L, 15L, 16L, 18L, 18L, 17L, 17L, 16L, 17L, 17L, 17L, 13L,
14L, 18L, 21L, 22L, 21L, 20L, 22L, 20L, 20L, 10L, 9L, 6L,
20L, 27L, 25L, 22L, 21L, 21L, 23L, 23L, 22L, 22L, 24L, 28L,
30L, 21L, 8L, 8L, 13L, 17L, 18L, 19L, 15L, 22L, 26L, 27L,
16L, 11L, 11L, 13L, 13L, 11L, 10L, 11L, 11L, 10L, 9L, 6L,
5L, 15L, 26L, 27L, 25L, 22L, 21L, 16L, 20L, 26L, 26L, 26L,
11L, 10L, 12L, 15L, 16L, 16L, 16L, 17L, 18L, 17L, 12L, 10L,
8L, 15L, 27L, 24L, 24L, 21L, 19L, 18L, 21L), Feeding_Standing = c(4L,
4L, 4L, 11L, 11L, 10L, 12L, 10L, 10L, 10L, 11L, 10L, 10L,
11L, 13L, 17L, 7L, 5L, 4L, 7L, 6L, 9L, 8L, 7L, 9L, 7L, 6L,
16L, 21L, 16L, 15L, 14L, 14L, 15L, 15L, 15L, 16L, 17L, 19L,
21L, 11L, 7L, 6L, 11L, 16L, 15L, 14L, 13L, 10L, 7L, 7L, 16L,
19L, 18L, 14L, 15L, 14L, 14L, 18L, 16L, 17L, 15L, 17L, 21L,
14L, 6L, 8L, 10L, 13L, 15L, 12L, 12L, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, 12L, 10L, 7L, 19L, 26L, 25L, 22L, 23L, 24L,
25L, 24L, 24L, 25L, 25L, 27L, 29L, 19L, 7L, 7L, 11L, 15L,
14L, 19L, 15L, 14L, 11L, 10L, 25L, 28L, 26L, 23L, 22L, 22L,
22L, 24L, 23L, 24L, 26L, 28L, 29L, 24L, 10L, 12L, 15L, 17L,
20L, 18L, 18L), Standing_Foraging = c(24L, 25L, 26L, 23L,
21L, 22L, 22L, 22L, 22L, 20L, 18L, 20L, 21L, 21L, 18L, 14L,
22L, 25L, 25L, 24L, 23L, 23L, 24L, 24L, 20L, 22L, 22L, 14L,
12L, 16L, 16L, 17L, 17L, 16L, 15L, 16L, 15L, 17L, 16L, 17L,
17L, 22L, 22L, 18L, 15L, 16L, 15L, 19L, 20L, 23L, 22L, 15L,
13L, 13L, 14L, 15L, 14L, 13L, 14L, 15L, 14L, 13L, 16L, 17L,
16L, 20L, 21L, 19L, 18L, 16L, 19L, 18L, 28L, 29L, 30L, 22L,
19L, 20L, 21L, 20L, 21L, 21L, 22L, 22L, 24L, 24L, 26L, 30L,
26L, 29L, 28L, 27L, 28L, 26L, 27L, 27L, 28L, 27L, 28L, 23L,
23L, 25L, 25L, 25L, 26L, 26L, 26L, 25L, 26L, 27L, 28L, 30L,
26L, 28L, 28L, 28L, 30L, 26L, 25L, 27L, 27L, 31L, 28L, 25L,
28L, 25L, 23L, 21L, 22L, 23L, 20L, 21L, 20L, 22L, 24L, 27L,
23L, 28L, 28L, 27L, 26L, 26L, 24L, 26L), Day_Night = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L), .Label = c("Day", "Night"
), class = "factor")), row.names = c(NA, -144L), class = c("data.table",
"data.frame"), .internal.selfref = <pointer: 0x00000000025e1ef0>)