首页 > 解决方案 > R:无法使用特征的平方进行线性回归

问题描述

我有下面使用内置数据集的代码mtcars

data(mtcars)
model_1 <- lm(mpg ~ wt + log(wt), data = mtcars)
summary(model_1)

model_2 <- lm(mpg ~ wt + wt^2, data = mtcars)
summary(model_2)

model_1中,事情运行良好,我有两个特征wtlog(wt)在我的回归结果中。

但是在 中model_2,我只有wt在结果中,而我没有 的平方wt。为什么以及如何解决?

标签: rstatisticsregressionlinear-regressionlm

解决方案


推荐阅读