【问题标题】:Getting coefficients for explanatory variables not in the formula [duplicate]获取不在公式中的解释变量的系数[重复]
【发布时间】:2021-09-11 23:49:11
【问题描述】:

我有: model6 = get_model(formula="log(Y_star)~X_1_star*X_3_star", df=df)

模型总结给了我:

Coefficients:
                    Estimate Std. Error t value Pr(>|t|)    
(Intercept)       -1.049e+01  3.724e-01 -28.182  < 2e-16 ***
X_1_star           3.082e-08  7.517e-09   4.100 8.44e-05 ***
X_3_star           3.482e-07  8.708e-08   3.999 0.000122 ***
X_1_star:X_3_star -6.716e-15  7.822e-16  -8.587 1.22e-13 ***

当 X_1_star 和 X_3_star 不在公式中时,为什么要分别给出它们的系数?

我的公式是不是 Y = b_0 + b_1*X_1_star + b_2*X_3_star + b_3*X_1_star*X_3_star

【问题讨论】:

  • X_1_star*X_3_star 当您使用 * 时,它会考虑每个变量及其在模型中的交互作用
  • 如果你只想X_1_star:X_3_starget_model(formula="log(Y_star)~X_1_star:X_3_star", df=df)
  • @ViníciusFélix 这太奇怪了!为什么他们如此神秘地实现它??

标签: r linear-regression


【解决方案1】:

根据?formula

* 运算符表示因子交叉:a*b 解释为 a+b+a:b

根据评论,如果我们只想要交互,那么使用不同的符号

术语本身由变量和因子名称组成,由 : 运算符分隔。这样的术语被解释为术语中出现的所有变量和因素的相互作用。

【讨论】:

  • 那么如何表示单个解释变量a 乘以b
  • model6 = get_model(formula="log(Y_star)~X_1_star:X_3_star", df=df)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-10-06
  • 1970-01-01
  • 2014-02-15
  • 1970-01-01
  • 1970-01-01
  • 2013-07-01
相关资源
最近更新 更多