Trains a Random Forest with k-fold cross-validation on a candidate
sample design and returns the mean squared error for a chosen response
covariate. Used as the objective function for ss_rf_optimize().
Arguments
- sample_points
Data frame with
x,yas the first two columns followed by covariate columns (as returned byss_clhs_sample()).- full_data
Optional data frame of the full covariate population; if supplied,
sample_pointsis restricted to the shared columns.- n_folds
Integer, number of cross-validation folds. Default
5.- target_var
Character, name of the covariate to predict. If
NULL(default), the third covariate column is used, or the first if fewer than three are available.
Value
Numeric, the mean cross-validated MSE, or NA_real_ if the
design has too few rows/columns or every fold fails.
Examples
if (FALSE) { # \dontrun{
samples <- ss_clhs_sample(r, n_samples = 100, seed = 1)
ss_rf_mse(samples)
} # }
