问题标签 [tradeoff]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
175 浏览

r - 在 R 中寻找内核平滑回归的最佳带宽

我模拟了双变量数据 (x,y),其中 y 的平均值为 1/x 和一些方差。数据看起来像这样:数据

我正在使用内核平滑回归来尝试找到这种关系。

kernelreg = ksmooth( train_points$x, train_points$y, kernel = "normal", bandwidth = h) plot(y~x, train_points , cex = 0.5, col = "dodgerblue", main = "Data set") lines(kernelreg,lwd = 2, col = 2)

我想知道如何编写一个函数来通过带宽列表运行此回归并计算训练和测试数据中的 rmse。从而显示使模型误差最小化的最佳带宽。