gpt4 book ai didi

r - loess 用新的 x 值预测

转载 作者:行者123 更新时间:2023-12-04 02:05:37 26 4
gpt4 key购买 nike

我试图了解 predict.loess函数能够计算点 y_hat 处的新预测值 ( x )原始数据中不存在的。例如(这是一个简单的例子,我意识到这种例子显然不需要黄土,但它说明了这一点):

x <- 1:10
y <- x^2
mdl <- loess(y ~ x)
predict(mdl, 1.5)
[1] 2.25
loess回归的工作原理是在每个 x 处使用多项式因此它创建了一个预测 y_hat在每个 y .但是,由于没有存储系数,因此在这种情况下,“模型”只是用于预测每个 y_hat 的详细信息。 ,例如 spandegree .当我这样做时 predict(mdl, 1.5) ,怎么样 predict能够在这个新的 x 产生一个值?是否在两个最近的现有 x 之间进行插值值及其关联 y_hat ?如果是这样,它是如何做到这一点背后的细节是什么?

我已阅读 cloess在线文档,但我无法找到它讨论这个的地方。

最佳答案

However, because there are no coefficients being stored, the "model" in this case is simply the details of what was used to predict each y_hat



也许你用过 print(mdl)命令或简单地 mdl看什么型号 mdl包含,但事实并非如此。该模型非常复杂,并存储了大量参数。

要了解里面的内容,您可以使用 unlist(mdl)并查看其中的大参数列表。

这是描述其实际工作方式的命令手册的一部分:

Fitting is done locally. That is, for the fit at point x, the fit is made using points in a neighbourhood of x, weighted by their distance from x (with differences in ‘parametric’ variables being ignored when computing the distance). The size of the neighbourhood is controlled by α (set by span or enp.target). For α < 1, the neighbourhood includes proportion α of the points, and these have tricubic weighting (proportional to (1 - (dist/maxdist)^3)^3). For α > 1, all points are used, with the ‘maximum distance’ assumed to be α^(1/p) times the actual maximum distance for p explanatory variables.

For the default family, fitting is by (weighted) least squares. For family="symmetric" a few iterations of an M-estimation procedure with Tukey's biweight are used. Be aware that as the initial value is the least-squares fit, this need not be a very resistant fit.



我相信它试图在每个点的邻域中拟合多项式模型(不仅仅是整个集合的单个多项式)。但是邻域并不意味着只有一点之前和之后的一点,如果我要实现这样的函数,我会在离点 x 最近的点上施加很大的权重,而对远端点施加较低的权重,并尝试拟合一个多项式适合最高的总重量。

然后,如果应该预测高度的给定 x' 最接近点 x,我尝试使用拟合在点 x 的邻域上的多项式 - 比如说 P(x) - 并将其应用于 x' - 比如说 P(x ') - 这就是预测。

如果您正在寻找任何特别的东西,请告诉我。

关于r - loess 用新的 x 值预测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12822069/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com