Skip to content

Commit 1679aa7

Browse files
authored
fix process_init_approx (#984)
1 parent f141d06 commit 1679aa7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

R/args.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,8 @@ process_init_approx <- function(init, num_procs, model_variables = NULL,
12901290
model_variables = list(parameters = colnames(draws_df)[3:(length(colnames(draws_df)) - 3)])
12911291
}
12921292
draws_df$lw = draws_df$lp__ - draws_df$lp_approx__
1293+
# Replace NaN and Inf with -Inf
1294+
draws_df$lw[!is.finite(draws_df$lw)] <- -Inf
12931295
# Calculate unique draws based on 'lw' using base R functions
12941296
unique_draws = length(unique(draws_df$lw))
12951297
if (num_procs > unique_draws) {
@@ -1315,7 +1317,7 @@ process_init_approx <- function(init, num_procs, model_variables = NULL,
13151317
draws_df$weight = exp(draws_df$lw - max(draws_df$lw))
13161318
} else {
13171319
draws_df$weight = posterior::pareto_smooth(
1318-
exp(draws_df$lw - max(draws_df$lw)), tail = "right", return_k=FALSE)
1320+
exp(draws_df$lw - max(draws_df$lw)), tail = "right", r_eff=1, return_k=FALSE)
13191321
}
13201322
init_draws_df = posterior::resample_draws(draws_df, ndraws = num_procs,
13211323
weights = draws_df$weight, method = "simple_no_replace")

0 commit comments

Comments
 (0)