Leave-one-out cross validation for IDW in R

核能气质少年 提交于 2019-12-12 03:55:14

问题


I am trying to check the results of IDW interpolation by leave-one-out cross validation and then get the RMSE to see the quality of the prediction.

From github Interpolation in R, I found some hints and apply it in my case as following:

I have 63 locations which is saved as a SpatialPointDataFrame, named x_full_utm_2001. For each location, there is attached precipitation data, named sumdata_2001.

idw.out<- vector(length = length(sumdata_2001$Jan))
for (i in 1:length(sumdata_2001$Jan)) {
  idw.out[i]<-idw(sumdata_2001$Jan~1, x_full_2001_utm[-i, ], x_full_2001_utm[i, ])$var1.pred
}

But I don't know why there is always error warning me as follows:

dimensions do not match: locations 124 and data 63

I'm wondering why it works out like this. How should I revise this?

来源:https://stackoverflow.com/questions/41831519/leave-one-out-cross-validation-for-idw-in-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!