diff --git a/R/helpers.R b/R/helpers.R index e5b26d45..c2d6102e 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -57,7 +57,7 @@ validate_ll <- function(x) { stop("List not allowed as input.") } else if (anyNA(x)) { stop("NAs not allowed in input.") - } else if (any(x==Inf)) { + } else if (any(x == Inf)) { stop("All input values must be finite or -Inf.") } invisible(x) diff --git a/R/split_moment_matching.R b/R/split_moment_matching.R index 47f81ad8..b7bdb111 100644 --- a/R/split_moment_matching.R +++ b/R/split_moment_matching.R @@ -100,7 +100,7 @@ loo_moment_match_split <- function(x, upars, cov, total_shift, total_scaling, # lwi_half may have NaNs if computation involves -Inf + Inf # replace NaN log ratios with -Inf - lr<-lwi_half + lr <- lwi_half lr[is.na(lr)] <- -Inf is_obj_half <- suppressWarnings(importance_sampling.default(lr, method = is_method, @@ -110,7 +110,7 @@ loo_moment_match_split <- function(x, upars, cov, total_shift, total_scaling, # lwi_half may have NaNs if computation involves -Inf + Inf # replace NaN log ratios with -Inf - lr<-lwi_half + log_liki_half + lr <- lwi_half + log_liki_half lr[is.na(lr)] <- -Inf is_obj_f_half <- suppressWarnings(importance_sampling.default(lr, method = is_method,