From 29884341fd0ea96995bedd83ca2203fbc36ad9d0 Mon Sep 17 00:00:00 2001 From: Philina English Date: Sat, 19 Oct 2024 12:21:53 -0700 Subject: [PATCH] fix bug in invert_chains.R When more than 1 chain required inversion, this error was occuring: Error in if (flipped_chains == 0) { : the condition has length > 1 --- R/invert_chains.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/invert_chains.R b/R/invert_chains.R index 3ba6984..d3b38dd 100644 --- a/R/invert_chains.R +++ b/R/invert_chains.R @@ -68,7 +68,7 @@ find_inverted_chains <- function(model, trend = 1, plot = FALSE) { sq_err <- sum((zzz[, i] - pred0_loadings)^2) + sum((vvv[, i] - pred0_trend)^2) # if flipped trends/loadings more similar to chain 1, flip if (flipped_sq_err < sq_err) { - if (flipped_chains == 0) { + if (min(flipped_chains) == 0) { flipped_chains <- i } else {