r - 将常数定义为 r 回归的系数
问题描述
我正在尝试将常数定义为 r 回归的系数。即试图将弹性定义为您在照片中看到的数字 -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
非常感谢任何帮助!:)
解决方案
elasticity <- reg$coefficients[names(reg$coefficients)=="ln_price"]
推荐阅读
- html - 为什么我的尺寸属性不起作用?如何解决这个问题?
- android - 使用 Cupertino 分段控制在第一页正文中打开第二页
- java - 重构:删除构造函数中的重复项
- mongodb - Mongodb bulkwrite updateOne 基于数组最后一个元素中的日期
- javascript - 使用 rxjs 的搜索功能问题
- sql - SQL中Date_Trunc的格式(Redshift)
- sed - 使用 sed 从命令输出中提取模式返回整个命令而不是仅匹配的子字符串
- java - bootstrap.properties 的替换和注入不起作用
- javascript - 使用对象迭代映射
- python - 如何将整个列表存储在一列的单行中?