From 22f37ec51c29e8f052a14d76d4fc04fc91461bd7 Mon Sep 17 00:00:00 2001 From: martyn Date: Sat, 7 Feb 2026 19:33:21 +0000 Subject: [PATCH 1/2] Updates for ggplot2 --- tests/testthat/helper-runs.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testthat/helper-runs.R b/tests/testthat/helper-runs.R index 47b8973..0204e71 100644 --- a/tests/testthat/helper-runs.R +++ b/tests/testthat/helper-runs.R @@ -162,14 +162,14 @@ test_plot = function(fit, varying_cols) { is_expected = any(stringr::str_detect(error_message, expected_error)) expect_true(is_expected) } else { - testthat::expect_true(ggplot2::is.ggplot(gg)) + testthat::expect_true(ggplot2::is_ggplot(gg)) } } # Test plot() calls to bayesplot test_plot_pars = function(fit) { gg = plot_pars(fit, type = "dens_overlay") - testthat::expect_true(ggplot2::is.ggplot(gg)) + testthat::expect_true(ggplot2::is_ggplot(gg)) } @@ -194,7 +194,7 @@ test_hypothesis = function(fit) { # Varying if (!is.null(fit$pars$varying)) { - mcmc_vars = colnames(mcmclist_samples(fit)[[1]]) + mcmc_vars = colnames(mcp:::mcmclist_samples(fit)[[1]]) varying_starts = paste0("^", fit$pars$varying[1]) varying_col_ids = stringr::str_detect(mcmc_vars, varying_starts) varying_cols = paste0("`", mcmc_vars[varying_col_ids], "`") # Add these for varying @@ -298,7 +298,7 @@ test_pp_eval = function(fit) { testthat::expect_true(error_message) } } else { - testthat::expect_true(ggplot2::is.ggplot(pp_default)) + testthat::expect_true(ggplot2::is_ggplot(pp_default)) } } From bf261fba25645b712d31663ce5d0e6e2e21ac583 Mon Sep 17 00:00:00 2001 From: martyn Date: Sat, 7 Feb 2026 19:34:20 +0000 Subject: [PATCH 2/2] Updates for JAGS 5.0.0 --- R/get_formula.R | 2 +- R/get_jagscode.R | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/get_formula.R b/R/get_formula.R index 2aa968e..8250386 100644 --- a/R/get_formula.R +++ b/R/get_formula.R @@ -152,7 +152,7 @@ get_formula_str = function(ST, par_x, ytype = "ct", init = FALSE) { if (ytype == "ct") { formula_str = paste0(formula_str, "\n\n# Fitted value\ny_[i_] = \n") } else if (ytype == "sigma") { - formula_str = paste0(formula_str, "# Fitted standard deviation\nsigma_[i_] = max(0, \n") # Add max(0, [formula]) to prevent modeling negative sigmas. JAGS uses precision = 1 / sigma^2 which yields positive precisions for negative sigmas. + formula_str = paste0(formula_str, "# Fitted standard deviation\nsigma_[i_] = max(0.001, \n") # Add max(0, [formula]) to prevent modeling negative sigmas. JAGS uses precision = 1 / sigma^2 which yields positive precisions for negative sigmas. } else if (stringr::str_detect(ytype, "ar[0-9]+")) { formula_str = paste0(formula_str, "# Autoregressive coefficient for all AR(", ar_order,")\n", ytype, "_[i_] = \n") } else if (stringr::str_detect(ytype, "ma[0-9]+")) { diff --git a/R/get_jagscode.R b/R/get_jagscode.R index a74a3d3..daad7a9 100644 --- a/R/get_jagscode.R +++ b/R/get_jagscode.R @@ -145,7 +145,9 @@ get_jagscode = function(prior, ST, formula_str, arma_order, family, sample) { # Compute residuals for AR if (has_ar) { if (family$family == "binomial") { - mm = paste0(mm, "\n resid_abs_[i_] = ", family$linkfun_str, "(", ST$y[1], "[i_] / ", ST$trials[1], "[i_]) - y_[i_] # Residuals represented by sigma_ after ARMA") + mm = paste0(mm, "\n resid_abs_[i_] = ", family$linkfun_str, "(0.01 + 0.98 * ", ST$y[1], "[i_] / ", ST$trials[1], "[i_]) - y_[i_] # Residuals represented by sigma_ after ARMA") + } else if (family$family == "poisson") { + mm = paste0(mm, "\n resid_abs_[i_] = ", family$linkfun_str, "(0.01 + ", ST$y[1], "[i_]) - y_[i_] # Residuals represented by sigma_ after ARMA") } else { mm = paste0(mm, "\n resid_abs_[i_] = ", family$linkfun_str, "(", ST$y[1], "[i_]) - y_[i_] # Residuals represented by sigma_ after ARMA") }