简体   繁体   English

如何从R中的glm函数结果中获取因变量名?

[英]How to get dependent variable name from glm function outcome in R?

I have r code of GLM created by one of my ex colleague. 我有一个由前任同事创建的GLM代码。 The code looks like 代码看起来像

 glm_mod <- glm(formula
           , data
           ,weights=sqrt(units_x+units_y)
           ,family = quasibinomial(link="logit")

Formula defined the relationship between dependent & independent variable. Formula定义了依赖变量和自变量之间的关系。 I found there is an issue in formula. 我发现配方中存在问题。 It's using incorrect dependent variable but my client is not ready to accept as the code was developed by one of their high efficient ex employee. 它使用了不正确的因变量但我的客户端还没准备好接受,因为代码是由他们的高效前雇员之一开发的。 They want me to show the dependent variable name from the glm outcome. 他们希望我从glm结果中显示因变量名称。 Can you suggest me how should I get dependent variable name from glm outcome? 你能告诉我如何从glm结果获得因变量名?

You should able to see which is the dependent variable from the formula object with just subsetting: 您应该只使用子集来查看公式对象中的因变量:

formula <- as.formula("y ~ x + b")
formula[[2]]
y
# or 
all.vars(formula)[1]
[1] "y"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM