【发布时间】:2015-04-06 20:25:53
【问题描述】:
如何从locfit.robust 的输出中提取预测?
我已经知道如何绘制它,但我不知道如何实际提取预测。示例数据如下。
df <-
structure(list(x = c(45.0166666666667, 2.93361111111111, 22.7677777777778,
34.6702777777778, 38.9808333333333, 2.07138888888889, 49.3283333333333,
19.3177777777778, 42.4305555555556, 11.5561111111111, 29.6677777777778,
6.38222222222222, 30.5302777777778, 52.775, 35.5325, 56.3958333333333,
25.3544444444444, 10.6936111111111, 44.155, 31.3919444444444,
13.2811111111111, 58.9841666666667, 7.24444444444444, 20.1802777777778,
15.0061111111111, 51.0508333333333, 8.96916666666667, 32.945,
27.9430555555556, 28.8055555555556, 3.79611111111111, 18.4558333333333,
8.10694444444444), y = c(17.1906619704517, 51.3682492415682,
34.5954944745371, 33.1782496417985, 28.8639252539494, 67.2499473509127,
15.5739106117996, 29.7082944904524, 19.5924660810231, 27.6320399707289,
30.09868839615, 33.7360588582795, 31.0412412696196, 85.8932775978829,
29.6595900511557, 14.006526734448, 36.4282036185057, 25.3450383921273,
17.0527246335207, 33.306938081975, 27.5846864057136, 15.9395044691672,
28.7380574036629, 27.2409001620039, 26.5896320563312, 15.9792323783856,
29.1293971960009, 94.2788150401981, 32.613338976917, 30.9617968951112,
43.3449335001097, 30.6310217270105, 29.7063251039514)), .Names = c("x",
"y"), class = c("tbl_df", "data.frame"), row.names = c(NA, -33L
))
我可以用以下方法绘制数据:
library(locfit)
with(df, plot(x = x, y = y))
fit <- with(df, locfit.robust(x = x, y = y))
lines(fit)
但是如何提取x 的每个值的预测?
> predict(fit)
[1] 46.70358 13.45021 32.58037 27.64739 20.74407
我不知道这些值是什么。
【问题讨论】: