如何用GGPLOT绘制两个估计值

发布于 2025-02-11 19:25:12 字数 150 浏览 1 评论 0原文

为此,最有效的GGPLOT代码是什么? “

在我的数据集中,我计算了两个我想比较图片所示的估计值。有一些示例代码吗?估计值由LME()计算

What is the most efficient ggplot code for this?
1

In my dataset, I calculated two estimates that I want to compare As shown in the picture. Is there some example code? The estimates are calculated by lme()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉默的熊 2025-02-18 19:25:12

我假设您指的是nlme :: lme,那么这是使用Orthodont-Dataset的最小示例,假设您对固定效应 - 零件感兴趣(否则,可以相应地对此进行相应的效果(否则)

library(nlme)
library(tidyverse)
library(broom.mixed)


fm1 <- lme(distance ~ age, data = Orthodont, subset = Sex == "Female")
fm2 <- lme(distance ~ age, data = Orthodont, subset = Sex == "Male")

est1 <- tidy(fm1) %>% filter(effect == "fixed")
est2 <- tidy(fm2) %>% filter(effect == "fixed")

ggplot() +
  geom_pointrange(aes(estimate, term, xmin = estimate - std.error, xmax = estimate + std.error ),
                  data = est1, position = position_nudge(y = 0.1), color = "red") +
  geom_pointrange(aes(estimate, term, xmin = estimate - std.error, xmax = estimate + std.error ),
                  data = est2, position = position_nudge(y = -0.1), color = "blue")

“”

reprex软件包(v2.0.1)

I'm assuming you are referring to nlme::lme, then here is a minimal example using the Orthodont-dataset, assuming you are interested in the fixed effect-parts (otherwise this can be ajusted accordingly)

library(nlme)
library(tidyverse)
library(broom.mixed)


fm1 <- lme(distance ~ age, data = Orthodont, subset = Sex == "Female")
fm2 <- lme(distance ~ age, data = Orthodont, subset = Sex == "Male")

est1 <- tidy(fm1) %>% filter(effect == "fixed")
est2 <- tidy(fm2) %>% filter(effect == "fixed")

ggplot() +
  geom_pointrange(aes(estimate, term, xmin = estimate - std.error, xmax = estimate + std.error ),
                  data = est1, position = position_nudge(y = 0.1), color = "red") +
  geom_pointrange(aes(estimate, term, xmin = estimate - std.error, xmax = estimate + std.error ),
                  data = est2, position = position_nudge(y = -0.1), color = "blue")

Created on 2022-06-29 by the reprex package (v2.0.1)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文