【问题标题】:Defining a constant as a coefficient from an r regression [duplicate]将常数定义为 r 回归的系数
【发布时间】:2020-05-09 05:00:54
【问题描述】:

我正在尝试将常数定义为 r 回归的系数。 IE。试图将弹性定义为您在照片中看到的数字 -1.64431。

reg <- lm(ln_q ~ ln_price, data=df) 
elasticity <- reg[["coefficients","ln_price"]]
print(elasticity)

我得到错误:

Error in reg[["coefficients", "ln_price"]] : 
  incorrect number of subscripts

非常感谢任何帮助! :)

【问题讨论】:

  • 我猜你可能想要 - coef(reg)["ln_price"] ?

标签: r regression constants coefficients


【解决方案1】:
elasticity <- reg$coefficients[names(reg$coefficients)=="ln_price"]

【讨论】:

  • 请解释您的答案,以便其他人理解。只发布代码是行不通的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-05-17
  • 2020-02-14
  • 2017-11-24
  • 1970-01-01
  • 2019-06-06
  • 2019-09-28
  • 1970-01-01
相关资源
最近更新 更多