Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们可以在 R 中生成正交多项式, pp <- poly(cars$speed, 2) 有没有办法从结果中获取原始值pp(逆多元函数)?
pp <- poly(cars$speed, 2)
pp
换句话说,该函数应该f返回以下结果:
f
f(poly(cars$speed, 2)) == cars$speed?
f(poly(cars$speed, 2)) == cars$speed
cars$speed对于某些标量 a 和 b 必须是 a + b * pp[, 1] 的形式,并且知道coefspoly 对象的属性包含可用于重建的值,我们发现cars$speedas的以下重建speed。
cars$speed
coefs
speed
pp <- poly(cars$speed, 2) speed <- with(attr(pp, "coefs"), alpha[1] + sqrt(norm2)[3] * pp[, 1]) all.equal(speed, cars$speed) ## [1] TRUE