如何在R中的混合效应线性模型中解释分类系数?

时间:2019-12-30 15:31:33

标签: r linear-regression categorical-data multi-level coefficients

我想知道如何在这个多层次模型中解释我的系数“饮食”。 “饮食”类别是1-4,指的是小鸡的饮食习惯。时间以天为单位,重量以克为单位。因此,小鸡的体重都会随着时间的推移而增加,但是由于饮食的不同,它们的增长速度也不同。 “小鸡”是小鸡的唯一ID。

使用下面的代码,您应获得MLE估计/系数,其截距为23.23,时间为8.443,饮食为2.979

我看到随着时间增加1个单位,重量增加8.443。但是,当Diet作为“绝对变量”时,“ 3”导致的体重增加比“ 4”更多的话,这又如何呢? (我从绘制数据知道这一点,请参见下面的代码)。

也许这是一个建模问题,我做错了。饮食变量本质上是否需要是文本,所以R虚拟变量将其编码吗?

如果需要,有关数据的信息在这里:http://vincentarelbundock.github.io/Rdatasets/doc/datasets/ChickWeight.html

谢谢。

library(tidyverse)
library(lme4)
library(lmerTest)

chickdiet <- read_csv('http://vincentarelbundock.github.io/Rdatasets/csv/datasets/ChickWeight.csv')

chickm3 <- lmer(weight ~ Time + Diet + (Time | Chick), data = chickdiet)

summary(chickm3)

#from plotting the data with the code below I can see that the diet that increases the chicks' weight the most, in ascending order are 1, 2, 4, 3

ggplot(chickdiet, aes(x = Time, y = weight, colour = as.factor(Diet))) + geom_point() +
  stat_smooth(method = lm, se = F) + theme_minimal()

0 个答案:

没有答案
相关问题