【问题标题】:extract predictor names from (generalized) linear models in R从 R 中的(广义)线性模型中提取预测变量名称
【发布时间】:2022-01-22 23:20:28
【问题描述】:

当预测变量是因子(类别)时,coef(glm)summary(glm) 列出所有虚拟变量。有没有办法将模型中存在的变量名称作为字符向量列出,而不将单个因子拆分为 C-1 个虚拟变量?

【问题讨论】:

    标签: r linear-regression


    【解决方案1】:

    对不起,我自己想通了:

    attr(glm$terms, "term.labels")
    

    【讨论】:

    • 虽然在公式 e..~ I(var1^2) + factor(var2) 中使用函数时,这可能无法满足您的需求。也许像all.vars(formula(m))[-1] 这样的东西会适合
    猜你喜欢
    • 1970-01-01
    • 2014-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多