如何使用r中的GLM获得相互作用的p值和CI的效果

发布于 2025-02-12 10:49:43 字数 794 浏览 1 评论 0原文

在多变量GLM模型中,我需要计算以下交互项目的简单效果: 性别(女性与男性)*不愉快(是与否)

该模型具有as.factor变量,我的参考变量为男性= 1,不及时容纳(no)= 0。 在我的模型中,女性= 2并且不稳定地容纳(是)= 1

我编写了以下代码,但不确定如何计算上述每个类别的OR,CI和不同的p值。

model <- glm(depression ~ as.factor(unstablyhoused) + as.factor(SEXBRTH) + as.factor(unstablyhoused)*as.factor(SEXBRTH), 
             data=mergedata, family = binomial(link='logit'), na.action = na.omit)
summary(model)
confint(model)
exp(coef(model))
exp(cbind(OR = coef(model), confint(model)))

我的问题是如何计算OR,置信区间(95%CI),以及相互作用的效果的P值:

  1. 在那些不及时的性爱的人中(女性与男性)(女性与男性)
  2. (女性)(女性与男性)在那些不舒服地安置的人中
  3. (是的,是与否)中的女性
  4. (是的)(是的

)计算1-4个项目,将不胜感激。 的OR,置信区间和p值

我需要知道简单主要效果模型图 “

In a multivariable GLM model, I need to calculate the simple effects of the following interaction item:
sex (female vs. male)*unstablyhoused (yes vs. no)

The model has as.factor variables, with my reference variables being Male = 1, unstably housed (no) = 0.
In my model, female = 2 and unstably housed (yes) = 1

I have written the following code but not sure how can I calculate the OR's, CI, and different p-values for each of the categories stated above.

model <- glm(depression ~ as.factor(unstablyhoused) + as.factor(SEXBRTH) + as.factor(unstablyhoused)*as.factor(SEXBRTH), 
             data=mergedata, family = binomial(link='logit'), na.action = na.omit)
summary(model)
confint(model)
exp(coef(model))
exp(cbind(OR = coef(model), confint(model)))

My question is how do I calculate the OR, confidence interval (95% CI), and p-values for the effect of the interaction when:

  1. sex(female vs. male) among those who are unstably housed
  2. sex (female vs. male) among those who do NOT unstably housed
  3. unstablyhoused (yes vs. no) among those that are female
  4. unstablyhoused (yes vs. no) among those that are NOT female

Any help and direction in what code to use to be able to calculate 1-4 items, would be greatly appreciated. I need to know the OR, confidence intervals, and p-value of the simple main effects

ModelOutput
1

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文