diff --git a/R/biomod2_classes_5.R b/R/biomod2_classes_5.R index 69327f56..bfee74fb 100644 --- a/R/biomod2_classes_5.R +++ b/R/biomod2_classes_5.R @@ -691,10 +691,11 @@ setMethod('predict2', signature(object = 'EMwmean_biomod2_model', newdata = "dat if (ncol(newdata) < 1) { stop("Model EMwmean was not computed because no single model was kept in ensemble modeling") } - predfun <- function(newdata, on_0_1000, penalization_scores, ...){ - out <- as.vector( - as.matrix(newdata) %*% penalization_scores - ) + predfun <- function(newdata, on_0_1000, penalization_scores, na.rm, ...){ + # out <- as.vector( + # as.matrix(newdata) %*% penalization_scores + # ) + out <- as.vector(rowSums(t(apply(as.matrix(newdata), 1, function(x) penalization_scores*x)), na.rm = na.rm)) if (on_0_1000) { out <- round(out) }