r - 在响应变量上运行 boxcox 时出错
问题描述
我正在使用以下代码尝试将我的响应变量转换为回归。似乎需要对数转换。
bc = boxCox(auto.tf.lm)
lambda.mpg = bc$x[which.max(bc$y)]
auto.tf.bc <- with(auto_mpg, data.frame(log(mpg), as.character(cylinders), displacement**.2, log(as.numeric(horsepower)), log(weight), log(acceleration), model_year))
auto.tf.bc.lm <- lm(log(mpg) ~ ., data = auto.tf.bc)
view(auto.tf.bc)
我收到了这个错误。
Error in Math.data.frame(mpg) :
non-numeric variable(s) in data frame: manufacturer, model, trans, drv, fl, class
不知道如何解决这个问题。数据在数据框中,而不是 csv。
这是 str(auto.tf.bc) 的输出。抱歉,问题格式如此糟糕。
'data.frame': 392 obs. of 7 variables:
$ log.mpg. : num 2.89 2.71 2.89 2.77 2.83 ...
$ as.character.cylinders.: chr "8" "8" "8" "8" ...
$ displacement.0.2 : num 3.14 3.23 3.17 3.14 3.13 ...
$ log.horsepower. : num 4.87 5.11 5.01 5.01 4.94 ...
$ log.weight. : num 8.16 8.21 8.14 8.14 8.15 ...
$ log.acceleration. : num 2.48 2.44 2.4 2.48 2.35 ...
$ model_year : num 70 70 70 70 70 70 70 70 70 70 ...
卸下气缸不会改变任何事情。
解决方案
推荐阅读
- c++ - 如何获取返回的向量引用?
- angular6 - 在我的 html (angular6) 中调用 ngFor 内的方法
- html - 全高引导网格 - 带有嵌套溢出-y:滚动
- python - 检查 Sqlite3 查询是否返回 null Flask
- random - 顽固分子在处理文件中的二进制数时如何知道这些数字有多“长”?
- python - keras 模型出错:预期 dense_53 有 2 个维度,但得到了形状为 (1, 1, 28, 28) 的数组
- spring-boot - JPA 实体映射上的重复列映射
- python - 为多类道路分割实现 U-net
- java - 在共享首选项中存储一维字符串数组
- python - 关于 python 请求中的代理