I have a SpatialPointsDataframe called rain and I would like to fit a variogram and perfom cross-validation for each one of its last 10 columns (dependent variables) like below:
fit.reg.vgm <- autofitVariogram(
column (dependent variable) ~ X + Y + Z + AS + SL,
rain,
model = c("Sph", "Exp", "Gau", "Lin", "Log"),
fix.values = c(NA, NA, NA),
verbose = FALSE,
GLS.model = NA,
start_vals = c(NA, NA, NA),
miscFitOptions = list()
)
cv <-krige.cv(column (dependent variable) ~ X + Y + Z + AS + SL, rain, fit.reg.vgm$var_model)
Does anyone know how to construct such a for-loop?
Thanks in advance!
You will need to construct a formula. Try
formula()
andpaste()
. Something along the lines of