小编use*_*688的帖子

使用 lmer 和预测时的“times”参数无效

我正在处理身体活动数据和后续疼痛数据。我有一个很大的数据集,但为了这个例子的摇动,我用我感兴趣的变量创建了一个小数据集。

由于我的身体活动数据本质上是组合的,因此我在使用这些变量作为混合效应模型中的预测变量之前使用组合数据分析。我的目标是使用 Predict() 函数来预测我创建的一些新数据,但我收到以下内容:

Error in rep(0, nobs) : invalid 'times' argument

我用谷歌搜索了一下,看到了几年前发布的一篇文章,但答案对我不起作用。

以下是数据集和我的代码:

library("tidyverse")
library("compositions")
library("robCompositions")
library("lme4")

dataset <- structure(list(work = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 
                              3L, 3L, 4L, 4L, 4L), .Label = c("1", "2", "3", "4"), class = "factor"), 
           department = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 
                                    3L, 4L, 4L, 4L), .Label = c("1", "2", "3", "4"), class = "factor"), 
           worker = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 
                                4L, 4L, 4L), …
Run Code Online (Sandbox Code Playgroud)

r predict lme4

5
推荐指数
1
解决办法
352
查看次数

标签 统计

lme4 ×1

predict ×1

r ×1