0

在使用“rstanarm”对回归模型尝试贝叶斯方法时,不允许重复的组特定术语。有什么解决办法吗?

Formula = "SleepTime ~ 1 + WorkingHours + (1 + WorkingHours | JobClass) + Tenure + (1 + Tenure | JobClass)"

bayesian = stan_lmer(Formula, data = data_model)

Error in check_reTrms(group) : rstanarm does not permit formulas with duplicate group-specific terms. In this case JobClass is used as a grouping factor multiple times and (Intercept) is included multiple times. Consider using || or -1 in your formulas to prevent this from happening.

4

1 回答 1

1

经过

考虑使用 || 或公式中的 -1 以防止这种情况发生。

代表着

SleepTime ~ 1 + WorkingHours + Tenure + (1 + WorkingHours | JobClass) + (-1 + Tenure | JobClass)

或者

SleepTime ~ 1 + WorkingHours + Tenure + (1 + WorkingHours + Tenure || JobClass)

将是有效的公式,对于每个JobClass.

于 2020-05-15T14:20:16.877 回答