我想做一个具有随机效应的多项式模型,但我不知道怎么做。
模型看起来像这样:
native_driftertype ~treat+(1|replica)+(1|compartment/originhive)
,native_driftertype
一个有 5 个水平的因素,treat
一个有 3 个水平的因素,replica
一个有 2 个水平的因素,compartment
一个有 3 个水平的因素,以及 originhive
一个有 24 个水平的因素。
数据是这样的:
data6 <- structure(list(origin_hive = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 3L, 3L, 19L, 3L, 3L, 19L, 3L, 3L, 3L, 3L, 19L, 19L, 19L,
3L, 3L, 3L, 6L, 9L, 6L, 6L, 6L, 6L, 9L, 6L, 9L, 9L, 6L, 6L, 6L,
9L, 6L, 8L, 16L, 8L, 16L, 16L, 16L, 8L, 16L, 16L, 16L, 8L, 1L,
1L, 23L, 14L, 1L, 23L, 1L, 23L, 1L, 3L, 7L, 3L, 19L, 3L, 9L,
9L, 9L, 6L, 9L, 16L, 16L, 8L, 1L, 23L, 1L, 23L, 14L, 3L, 3L,
7L, 7L, 9L, 11L, 11L, 16L, 16L, 8L, 21L, 23L, 1L, 23L, 19L, 3L,
19L, 19L, 19L, 19L, 6L, 6L, 6L, 11L, 11L, 6L, 6L, 6L, 6L, 9L,
9L, 6L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 1L, 14L, 1L,
10L, 13L, 10L, 10L, 13L, 13L, 13L, 10L, 20L, 24L, 24L, 5L, 20L,
20L, 20L, 5L, 20L, 24L, 5L, 5L, 20L, 12L, 17L, 12L, 12L, 12L,
15L, 12L, 12L, 12L, 17L, 17L, 17L, 12L, 15L, 15L, 12L, 12L, 17L,
12L, 15L, 17L, 12L, 12L, 12L, 12L, 12L, 22L, 22L, 2L, 4L, 22L,
2L, 22L, 2L, 13L, 18L, 13L, 5L, 5L, 12L, 17L, 22L, 22L, 22L,
22L, 13L, 13L, 18L, 18L, 18L, 20L, 20L, 20L, 20L, 5L, 5L, 5L,
5L, 24L, 5L, 5L, 12L, 17L, 17L, 12L, 17L, 12L, 4L, 10L, 13L,
18L, 13L, 10L, 5L, 5L, 24L, 20L, 20L, 20L, 5L, 20L, 24L, 12L,
17L, 12L, 17L, 17L, 12L, 17L, 22L, 22L), levels = c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, 1L,
2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 3L,
1L, 3L, 3L, 1L, 1L, 1L, 3L, 2L, 3L, 3L, 1L, 2L, 2L, 2L, 1L,
2L, 3L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 1L,
1L, 1L, 2L, 3L, 3L, 2L, 2L, 1L, 2L, 3L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 1L, 3L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L,
1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 3L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 3L, 3L, 1L,
2L, 1L, 3L, 1L, 1L, 3L, 2L, 2L, 2L, 1L, 2L, 3L, 2L, 1L, 2L,
1L, 1L, 2L, 1L, 2L, 2L), levels = c("12", "14", "16"), class = "factor")), row.names = c(NA, -464L
), class = "data.frame")
我尝试使用 brms 包中的 brm 函数(拟合贝叶斯广义(非)线性多元多级模型),但是在运行以下模型时,出现以下错误:
fit=brm(native_driftertype\~treat+(1|replica)+(1|compartment/origin_hive), family = multinomial, data = data6)
brm(native_driftertype ~ treat + (1 | replica) + (1 | compartment/origin_hive) 错误,: 未使用的参数(族 = 多项式,数据 = data6)