-->

Leave-one-out cross validation for IDW in R

2019-09-14 00:40发布

问题:

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?