if (FALSE) {
# This function is typically called internally during spatial predictor selection
# Example showing the structure of input data:
# Simulated optimization data frame
opt_data <- data.frame(
moran.i = c(0.5, 0.3, 0.2, 0.15),
r.squared = c(0.6, 0.65, 0.68, 0.69),
penalization.per.variable = c(0.1, 0.2, 0.3, 0.4),
p.value.binary = c(0, 0, 1, 1)
)
# Compute optimization scores
scores_moran <- optimization_function(
x = opt_data,
weight.r.squared = 0.5,
weight.penalization.n.predictors = 0.5,
optimization.method = "moran.i"
)
# Compare methods
scores_pvalue <- optimization_function(
x = opt_data,
weight.r.squared = 0.5,
weight.penalization.n.predictors = 0.5,
optimization.method = "p.value"
)
# Higher score indicates better solution
which.max(scores_moran)
which.max(scores_pvalue)
}
Run the code above in your browser using DataLab