绘制线性固定效应模型时,如何从 jtools 中的 interact_plots 中提取不同组的斜率和截距值
How to extract slope and intercept values for different groups from interact_plots in jtools when plotting linear fixed effects models
我正在尝试从我的线性混合效应模型中提取每个组的斜率和截距。该模型是使用 lme4 库中的 lmer 构建的,我可以使用 jtools 库中的 interact_plot 查看每个组的结果。如何获得每条线的斜率和截距?
我知道我可以使用 summary() 或 summ() 查看固定效应的估计值和随机效应的方差,但我看不到随机效应的估计值。因此,我无法准确计算模型的斜率和截距。
>library(lme4)
> cond_waterxsilver <- lmer(LnAg ~ LnVolume + (LnVolume | FilterID) + SilverType + WaterType + SilverType*WaterType + SilverType*LnVolume + WaterType*LnVolume, data=capwater_removed.data)
> library(jtools)
> interact_plot(cond_ranin_waterxsilver, pred = LnVolume, modx = WaterType, mod2 = SilverType)
我只是想从模型中获取六条线的斜率和截距(两种不同的 WaterType 和三种不同的 SilverType)。 jtools 或其他软件包中是否有可以帮助我从模型中提取斜率和截距的工具?
我是这个包的开发者!
简短说明:这个和我要提到的其他功能刚刚被移动到一个新包,称为 interactions
, which is in the process of being added to CRAN. Assuming you haven't updated to the newest version of jtools
(2.0.0; just came out days ago), these functions are still available in the jtools
package. If you do update to jtools
2.0.0, you'll need to follow this link 以获取有关如何下载 interactions
之前的说明CRAN.
您的问题应该有一个简单的答案。 sim_slopes
("simple slopes" 的缩写)函数应该可以满足您的需求。
sim_slopes(cond_ranin_waterxsilver, pred = LnVolume, modx = WaterType, mod2 = SilverType, cond.int = TRUE)
这将打印出条件斜率和截距(截距仅在 cond.int = TRUE
时打印。
如果您需要使用这些值进行编程,您可以保存 sim_slopes
对象。
ss <- sim_slopes(cond_ranin_waterxsilver, pred = LnVolume, modx = WaterType, mod2 = SilverType, cond.int = TRUE)
ss$slopes # Matrix of slopes with test statistics, etc.
ss$ints # Matrix of intercepts with test statistics, etc.
我正在尝试从我的线性混合效应模型中提取每个组的斜率和截距。该模型是使用 lme4 库中的 lmer 构建的,我可以使用 jtools 库中的 interact_plot 查看每个组的结果。如何获得每条线的斜率和截距?
我知道我可以使用 summary() 或 summ() 查看固定效应的估计值和随机效应的方差,但我看不到随机效应的估计值。因此,我无法准确计算模型的斜率和截距。
>library(lme4)
> cond_waterxsilver <- lmer(LnAg ~ LnVolume + (LnVolume | FilterID) + SilverType + WaterType + SilverType*WaterType + SilverType*LnVolume + WaterType*LnVolume, data=capwater_removed.data)
> library(jtools)
> interact_plot(cond_ranin_waterxsilver, pred = LnVolume, modx = WaterType, mod2 = SilverType)
我只是想从模型中获取六条线的斜率和截距(两种不同的 WaterType 和三种不同的 SilverType)。 jtools 或其他软件包中是否有可以帮助我从模型中提取斜率和截距的工具?
我是这个包的开发者!
简短说明:这个和我要提到的其他功能刚刚被移动到一个新包,称为 interactions
, which is in the process of being added to CRAN. Assuming you haven't updated to the newest version of jtools
(2.0.0; just came out days ago), these functions are still available in the jtools
package. If you do update to jtools
2.0.0, you'll need to follow this link 以获取有关如何下载 interactions
之前的说明CRAN.
您的问题应该有一个简单的答案。 sim_slopes
("simple slopes" 的缩写)函数应该可以满足您的需求。
sim_slopes(cond_ranin_waterxsilver, pred = LnVolume, modx = WaterType, mod2 = SilverType, cond.int = TRUE)
这将打印出条件斜率和截距(截距仅在 cond.int = TRUE
时打印。
如果您需要使用这些值进行编程,您可以保存 sim_slopes
对象。
ss <- sim_slopes(cond_ranin_waterxsilver, pred = LnVolume, modx = WaterType, mod2 = SilverType, cond.int = TRUE)
ss$slopes # Matrix of slopes with test statistics, etc.
ss$ints # Matrix of intercepts with test statistics, etc.