diff --git a/DESCRIPTION b/DESCRIPTION
index 84539943..251af531 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: serodynamics
Title: What the Package Does (One Line, Title Case)
-Version: 0.0.0.9043
+Version: 0.0.0.9044
Authors@R: c(
person("Peter", "Teunis", , "p.teunis@emory.edu", role = c("aut", "cph"),
comment = "Author of the method and original code."),
diff --git a/NEWS.md b/NEWS.md
index 38740944..012331d4 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -4,6 +4,7 @@
## New features
+* Adding `id` parameter to diagnostic functions (#121)
* Including fitted and residual values as data frame in run_mod output. (#101)
* Added `plot_predicted_curve()` with support for faceting by multiple IDs (#68)
* Replacing old data object with new run_mod output (#102)
diff --git a/R/add_jags_atts.R b/R/add_jags_atts.R
new file mode 100644
index 00000000..930f12e9
--- /dev/null
+++ b/R/add_jags_atts.R
@@ -0,0 +1,12 @@
+#' @title Adds attributes
+#' @description
+#' `add_jags_attrs` adds specified attributes to a [data.frame].
+#' @param df A [data.frame].
+#' @param attrs [attributes] to attach to the [data.frame].
+#' @param df A [data.frame] of the original input dataset.
+#' @returns A [data.frame] with specified [attributes] attached.
+#' @keywords internal
+add_jags_attrs <- function(df, attrs) {
+ attributes(df) <- c(attributes(df), attrs)
+ df
+}
diff --git a/R/plot_jags_densitydx.R b/R/plot_jags_densitydx.R
index 7e6a4e6d..6c191a09 100644
--- a/R/plot_jags_densitydx.R
+++ b/R/plot_jags_densitydx.R
@@ -26,6 +26,9 @@
#' - `y1` = posterior estimate of peak antibody concentration
#' @param strat Specify [character] string to produce plots of specific
#' stratification entered in quotes.
+#' @param id Specify [character] id in a [vector] format to produce plots for
+#' specific individuals. Default is the `newperson` referring to the predictive
+#' distribution.
#' @return A [base::list()] of [ggplot2::ggplot()] objects producing density
#' plots for all the specified input.
#' @export
@@ -34,45 +37,56 @@
plot_jags_dens <- function(data,
iso = unique(data$Iso_type),
param = unique(data$Parameter),
- strat = unique(data$Stratification)) {
+ strat = unique(data$Stratification),
+ id = c("newperson")) {
attributes_jags <- data[["attributes"]]
-
- dens_strat_list <- list()
- for (i in strat) {
+
+ dens_id_list <- list()
+ for (h in id) {
visualize_jags_sub <- data |>
- dplyr::filter(.data$Stratification == i) |>
- dplyr::filter(.data$Subject == "newperson")
+ dplyr::filter(.data$Subject == h)
+
+ stratify <- dplyr::intersect(unique(visualize_jags_sub$Stratification),
+ strat)
+
+ dens_strat_list <- list()
+ for (i in stratify) {
+
+ visualize_jags_strat <- visualize_jags_sub |>
+ dplyr::filter(.data$Stratification == i)
+
+ # Creating open list to store ggplots
+ density_out <- list()
+ # Looping through the isos
+ for (j in iso) {
+ visualize_jags_plot <- visualize_jags_strat |>
+ dplyr::filter(.data$Iso_type == j)
+
+ # Will not loop through parameters, as we may want each to show on the
+ # same plot by default.
+ visualize_jags_plot <- visualize_jags_plot |>
+ dplyr::filter(.data$Parameter %in% param)
- # Creating open list to store ggplots
- density_out <- list()
- # Looping through the isos
- for (j in iso) {
- visualize_jags_plot <- visualize_jags_sub |>
- dplyr::filter(.data$Iso_type == j)
+ visualize_jags_plot <- visualize_jags_plot |>
+ dplyr::mutate(Parameter = paste0("iso = ", j, ", parameter = ",
+ .data$Parameter, ", strat = ",
+ i),
+ value = log(.data$value))
- # Will not loop through parameters, as we may want each to show on the
- # same plot by default.
- visualize_jags_plot <- visualize_jags_plot |>
- dplyr::filter(.data$Parameter %in% param)
+ visualize_jags_plot <- add_jags_attrs(visualize_jags_plot,
+ attributes_jags)
- visualize_jags_plot <- visualize_jags_plot |>
- # Changing parameter name to reflect the input
- dplyr::mutate(Parameter = paste0("iso = ", j, ", parameter = ",
- .data$Parameter, ", strat = ",
- i),
- value = log(.data$value))
- # Assigning attributes, which are needed to run ggs_density
- attributes(visualize_jags_plot) <- c(attributes(visualize_jags_plot),
- attributes_jags)
- # Creating density plot
- densplot <- ggmcmc::ggs_density(visualize_jags_plot) +
- ggplot2::theme_bw() +
- ggplot2::labs(x = "log(value)")
- density_out[[j]] <- densplot
+ # Creating density plot
+ densplot <- ggmcmc::ggs_density(visualize_jags_plot) +
+ ggplot2::theme_bw() +
+ ggplot2::labs(x = "log(value)")
+ density_out[[j]] <- densplot
+ }
+ dens_strat_list[[i]] <- density_out
}
- dens_strat_list[[i]] <- density_out
+ dens_id_list[[h]] <- dens_strat_list
}
- dens_strat_list
+ dens_id_list
}
diff --git a/R/plot_jags_effectivedx.R b/R/plot_jags_effectivedx.R
index e94633c2..d709dfc7 100644
--- a/R/plot_jags_effectivedx.R
+++ b/R/plot_jags_effectivedx.R
@@ -27,6 +27,9 @@
#' - `alpha` = posterior estimate of decay rate
#' @param strat Specify [character] string to produce plots of specific
#' stratification entered in quotes.
+#' @param id Specify [character] id in a [vector] format to produce plots for
+#' specific individuals. Default is the `newperson` referring to the predictive
+#' distribution.
#' @return A [list] of [ggplot2::ggplot] objects showing the
#' proportion of effective samples taken/total samples taken for all parameter
#' iso combinations. The estimate with the highest proportion of effective
@@ -38,51 +41,62 @@
plot_jags_effect <- function(data,
iso = unique(data$Iso_type),
param = unique(data$Parameter),
- strat = unique(data$Stratification)) {
+ strat = unique(data$Stratification),
+ id = c("newperson")) {
attributes_jags <- data[["attributes"]]
+
+ eff_id_list <- list()
+ for (h in id) {
+
+ visualize_jags_sub <- data |>
+ dplyr::filter(.data$Subject == h)
- eff_strat_list <- list()
- for (i in strat) {
+ stratify <- dplyr::intersect(unique(visualize_jags_sub$Stratification),
+ strat)
- visualize_jags_sub <- data |>
- dplyr::filter(.data$Stratification == i) |>
- dplyr::filter(.data$Subject == "newperson")
+ eff_strat_list <- list()
+ for (i in stratify) {
+
+ visualize_jags_strat <- visualize_jags_sub |>
+ dplyr::filter(.data$Stratification == i)
- # Creating open list to store ggplots
- eff_out <- list()
- # Looping through the isos
- for (j in iso) {
- visualize_jags_plot <- visualize_jags_sub |>
- dplyr::filter(.data$Iso_type == j)
+ # Creating open list to store ggplots
+ eff_out <- list()
+ # Looping through the isos
+ for (j in iso) {
+ visualize_jags_plot <- visualize_jags_strat |>
+ dplyr::filter(.data$Iso_type == j)
- # Will not loop through parameters, as we may want each to show on the
- # same plot by default.
- visualize_jags_plot <- visualize_jags_plot |>
- dplyr::filter(.data$Parameter %in% param)
+ # Will not loop through parameters, as we may want each to show on the
+ # same plot by default.
+ visualize_jags_plot <- visualize_jags_plot |>
+ dplyr::filter(.data$Parameter %in% param)
- visualize_jags_plot <- visualize_jags_plot |>
- # Changing parameter name to reflect the input
- dplyr::mutate(Parameter = .data$Parameter)
- # Assigning attributes, which are needed to run ggs_density
- attributes(visualize_jags_plot) <- c(attributes(visualize_jags_plot),
- attributes_jags)
+ visualize_jags_plot <- visualize_jags_plot |>
+ # Changing parameter name to reflect the input
+ dplyr::mutate(Parameter = .data$Parameter)
+ # Assigning attributes, which are needed to run ggs_density
+ visualize_jags_plot <- add_jags_attrs(visualize_jags_plot,
+ attributes_jags)
- # Creating density plot
- eff <- ggmcmc::ggs_effective(visualize_jags_plot) +
- ggplot2::theme_bw() +
- ggplot2::labs(title = "Effective sample size",
- subtitle = plot_title_fun(i, j),
- x = "Proportion of effective samples") +
- ggplot2::scale_y_discrete(limits = c("alpha", "shape", "t1", "y1",
- "y0"))
- eff_out[[j]] <- eff
+ # Creating density plot
+ eff <- ggmcmc::ggs_effective(visualize_jags_plot) +
+ ggplot2::theme_bw() +
+ ggplot2::labs(title = "Effective sample size",
+ subtitle = plot_title_fun(i, j),
+ x = "Proportion of effective samples") +
+ ggplot2::scale_y_discrete(limits =
+ unique(visualize_jags_plot$Parameter))
+ eff_out[[j]] <- eff
+ }
+ eff_strat_list[[i]] <- eff_out
}
- eff_strat_list[[i]] <- eff_out
+ #Printing only one plot if only one exists.
+ if (sum(lengths(eff_strat_list)) == 1) {
+ eff_strat_list <- eff_strat_list[[1]][[iso]]
+ }
+ eff_id_list[[h]] <- eff_strat_list
}
- #Printing only one plot if only one exists.
- if (sum(lengths(eff_strat_list)) == 1) {
- eff_strat_list <- eff_strat_list[[1]][[iso]]
- }
- eff_strat_list
+ eff_id_list
}
diff --git a/R/plot_jags_rhatdx.R b/R/plot_jags_rhatdx.R
index f5535aaf..35f58a4f 100644
--- a/R/plot_jags_rhatdx.R
+++ b/R/plot_jags_rhatdx.R
@@ -29,6 +29,9 @@
#' - `alpha` = posterior estimate of decay rate
#' @param strat Specify [character] string to produce plots of specific
#' stratification entered in quotes.
+#' @param id Specify [character] id in a [vector] format to produce plots for
+#' specific individuals. Default is the `newperson` referring to the predictive
+#' distribution.
#' @return A [list] of [ggplot2::ggplot] objects producing dotplots with rhat
#' values for all the specified input.
#' @export
@@ -37,51 +40,64 @@
plot_jags_Rhat <- function(data, # nolint: object_name_linter
iso = unique(data$Iso_type),
param = unique(data$Parameter),
- strat = unique(data$Stratification)) {
+ strat = unique(data$Stratification),
+ id = c("newperson")) {
attributes_jags <- data[["attributes"]]
- rhat_strat_list <- list()
- for (i in strat) {
+ rhat_id_list <- list()
+ for (h in id) {
visualize_jags_sub <- data |>
- dplyr::filter(.data$Stratification == i) |>
- dplyr::filter(.data$Subject == "newperson")
+ dplyr::filter(.data$Subject == h)
+
+ stratify <- dplyr::intersect(unique(visualize_jags_sub$Stratification),
+ strat)
+
+ rhat_strat_list <- list()
+ for (i in stratify) {
+
+ visualize_jags_strat <- visualize_jags_sub |>
+ dplyr::filter(.data$Stratification == i)
- # Creating open list to store ggplots
- rhat_out <- list()
- # Looping through the isos
- for (j in iso) {
- visualize_jags_plot <- visualize_jags_sub |>
- dplyr::filter(.data$Iso_type == j)
+ # Creating open list to store ggplots
+ rhat_out <- list()
+ # Looping through the isos
+ for (j in iso) {
+ visualize_jags_plot <- visualize_jags_strat |>
+ dplyr::filter(.data$Iso_type == j)
- # Will not loop through parameters, as we may want each to show on the
- # same plot by default.
- visualize_jags_plot <- visualize_jags_plot |>
- dplyr::filter(.data$Parameter %in% param)
+ # Will not loop through parameters, as we may want each to show on the
+ # same plot by default.
+ visualize_jags_plot <- visualize_jags_plot |>
+ dplyr::filter(.data$Parameter %in% param)
- visualize_jags_plot <- visualize_jags_plot |>
- # Changing parameter name to reflect the input
- dplyr::mutate(Parameter = .data$Parameter,
- value = log(.data$value))
- # Assigning attributes, which are needed to run ggs_rhat
- attributes(visualize_jags_plot) <- c(attributes(visualize_jags_plot),
- attributes_jags)
- # Creating rhat dotplots
- rhatplot <- ggmcmc::ggs_Rhat(visualize_jags_plot) +
- ggplot2::theme_bw() +
- ggplot2::labs(title = "Rhat value",
- subtitle = plot_title_fun(i, j),
- x = "Rhat value") +
- ggplot2::scale_y_discrete(limits = c("alpha", "shape", "t1", "y1",
- "y0"))
- rhat_out[[j]] <- rhatplot
+ visualize_jags_plot <- visualize_jags_plot |>
+ # Changing parameter name to reflect the input
+ dplyr::mutate(Parameter = .data$Parameter,
+ value = log(.data$value))
+ # Assigning attributes, which are needed to run ggs_rhat
+ visualize_jags_plot <- add_jags_attrs(visualize_jags_plot,
+ attributes_jags)
+ # Default order of main parameters
+ param_levels <- c("alpha", "shape", "t1", "y1", "y0")
+ # Creating rhat dotplots
+ rhatplot <- ggmcmc::ggs_Rhat(visualize_jags_plot) +
+ ggplot2::theme_bw() +
+ ggplot2::labs(title = "Rhat value",
+ subtitle = plot_title_fun(i, j),
+ x = "Rhat value") +
+ ggplot2::scale_y_discrete(limits = intersect(param_levels,
+ param))
+ rhat_out[[j]] <- rhatplot
+ }
+ rhat_strat_list[[i]] <- rhat_out
}
- rhat_strat_list[[i]] <- rhat_out
+ #Printing only one plot if only one exists.
+ if (sum(lengths(rhat_strat_list)) == 1) {
+ rhat_strat_list <- rhat_strat_list[[1]][[iso]]
+ }
+ rhat_id_list[[h]] <- rhat_strat_list
}
- #Printing only one plot if only one exists.
- if (sum(lengths(rhat_strat_list)) == 1) {
- rhat_strat_list <- rhat_strat_list[[1]][[iso]]
- }
- rhat_strat_list
+ rhat_id_list
}
diff --git a/R/plot_jags_tracedx.R b/R/plot_jags_tracedx.R
index 9d2e632e..58ac6e90 100644
--- a/R/plot_jags_tracedx.R
+++ b/R/plot_jags_tracedx.R
@@ -26,6 +26,9 @@
#' - `y1` = posterior estimate of peak antibody concentration
#' @param strat Specify [character] string to produce plots of specific
#' stratification entered in quotes.
+#' @param id Specify [character] id in a [vector] format to produce plots for
+#' specific individuals. Default is the `newperson` referring to the predictive
+#' distribution.
#' @return A [list] of [ggplot2::ggplot] objects producing trace
#' plots for all the specified input.
#' @export
@@ -34,50 +37,62 @@
plot_jags_trace <- function(data,
iso = unique(data$Iso_type),
param = unique(data$Parameter),
- strat = unique(data$Stratification)) {
+ strat = unique(data$Stratification),
+ id = c("newperson")) {
attributes_jags <- data[["attributes"]]
-
- trace_strat_list <- list()
- for (i in strat) {
+
+ trace_id_list <- list()
+ for (h in id) {
visualize_jags_sub <- data |>
- dplyr::filter(.data$Stratification == i) |>
- dplyr::filter(.data$Subject == "newperson")
+ dplyr::filter(.data$Subject == h)
+
+ stratify <- dplyr::intersect(unique(visualize_jags_sub$Stratification),
+ strat)
+
+ trace_strat_list <- list()
+
+ for (i in stratify) {
+
+ visualize_jags_strat <- visualize_jags_sub |>
+ dplyr::filter(.data$Stratification == i)
- # Creating open list to store ggplots
- trace_out <- list()
- # Looping through the isos
- for (j in iso) {
- visualize_jags_plot <- visualize_jags_sub |>
- dplyr::filter(.data$Iso_type == j)
+ # Creating open list to store ggplots
+ trace_out <- list()
+ # Looping through the isos
+ for (j in iso) {
+ visualize_jags_plot <- visualize_jags_strat |>
+ dplyr::filter(.data$Iso_type == j)
- # Will not loop through parameters, as we may want each to show on the
- # same plot by default.
- visualize_jags_plot <- visualize_jags_plot |>
- dplyr::filter(.data$Parameter %in% param)
+ # Will not loop through parameters, as we may want each to show on the
+ # same plot by default.
+ visualize_jags_plot <- visualize_jags_plot |>
+ dplyr::filter(.data$Parameter %in% param)
- visualize_jags_plot <- visualize_jags_plot |>
- # Changing parameter name to reflect the input
- dplyr::mutate(Parameter = paste0("iso = ", j, ", parameter = ",
- .data$Parameter, ", strat = ",
- i))
- # Assigning attributes, which are needed to run ggs_density
- attributes(visualize_jags_plot) <- c(attributes(visualize_jags_plot),
- attributes_jags)
- # Creating density plot
- traceplot <- ggmcmc::ggs_traceplot(visualize_jags_plot) +
- ggplot2::theme_bw() +
- ggplot2::labs(x = "iterations", y = "parameter value") +
- ggplot2::theme(legend.position = "bottom") +
- ggplot2::scale_y_log10(labels = scales::label_comma())
- trace_out[[j]] <- traceplot
+ visualize_jags_plot <- visualize_jags_plot |>
+ # Changing parameter name to reflect the input
+ dplyr::mutate(Parameter = paste0("iso = ", j, ", parameter = ",
+ .data$Parameter, ", strat = ",
+ i))
+ # Assigning attributes, which are needed to run ggs_density
+ attributes(visualize_jags_plot) <- c(attributes(visualize_jags_plot),
+ attributes_jags)
+ # Creating density plot
+ traceplot <- ggmcmc::ggs_traceplot(visualize_jags_plot) +
+ ggplot2::theme_bw() +
+ ggplot2::labs(x = "iterations", y = "parameter value") +
+ ggplot2::theme(legend.position = "bottom") +
+ ggplot2::scale_y_log10(labels = scales::label_comma())
+ trace_out[[j]] <- traceplot
+ }
+ trace_strat_list[[i]] <- trace_out
}
- trace_strat_list[[i]] <- trace_out
+ #Printing only one plot if only one exists.
+ if (sum(lengths(trace_strat_list) == 1)) {
+ trace_strat_list <- trace_strat_list[[1]][[iso]]
+ }
+ trace_id_list[[h]] <- trace_strat_list
}
- #Printing only one plot if only one exists.
- if (sum(lengths(trace_strat_list) == 1)) {
- trace_strat_list <- trace_strat_list[[1]][[iso]]
- }
- trace_strat_list
+ trace_id_list
}
diff --git a/man/add_jags_attrs.Rd b/man/add_jags_attrs.Rd
new file mode 100644
index 00000000..2d8e119a
--- /dev/null
+++ b/man/add_jags_attrs.Rd
@@ -0,0 +1,20 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/add_jags_atts.R
+\name{add_jags_attrs}
+\alias{add_jags_attrs}
+\title{Adds attributes}
+\usage{
+add_jags_attrs(df, attrs)
+}
+\arguments{
+\item{df}{A \link{data.frame} of the original input dataset.}
+
+\item{attrs}{\link{attributes} to attach to the \link{data.frame}.}
+}
+\value{
+A \link{data.frame} with specified \link{attributes} attached.
+}
+\description{
+\code{add_jags_attrs} adds specified attributes to a \link{data.frame}.
+}
+\keyword{internal}
diff --git a/man/plot_jags_Rhat.Rd b/man/plot_jags_Rhat.Rd
index 753f42f6..c379af5f 100644
--- a/man/plot_jags_Rhat.Rd
+++ b/man/plot_jags_Rhat.Rd
@@ -8,7 +8,8 @@ plot_jags_Rhat(
data,
iso = unique(data$Iso_type),
param = unique(data$Parameter),
- strat = unique(data$Stratification)
+ strat = unique(data$Stratification),
+ id = c("newperson")
)
}
\arguments{
@@ -30,6 +31,10 @@ specific parameter, entered with quotes. Options include:
\item{strat}{Specify \link{character} string to produce plots of specific
stratification entered in quotes.}
+
+\item{id}{Specify \link{character} id in a \link{vector} format to produce plots for
+specific individuals. Default is the \code{newperson} referring to the predictive
+distribution.}
}
\value{
A \link{list} of \link[ggplot2:ggplot]{ggplot2::ggplot} objects producing dotplots with rhat
diff --git a/man/plot_jags_dens.Rd b/man/plot_jags_dens.Rd
index 91bffe5e..426387c6 100644
--- a/man/plot_jags_dens.Rd
+++ b/man/plot_jags_dens.Rd
@@ -8,7 +8,8 @@ plot_jags_dens(
data,
iso = unique(data$Iso_type),
param = unique(data$Parameter),
- strat = unique(data$Stratification)
+ strat = unique(data$Stratification),
+ id = c("newperson")
)
}
\arguments{
@@ -30,6 +31,10 @@ specific parameter, entered with quotes. Options include:
\item{strat}{Specify \link{character} string to produce plots of specific
stratification entered in quotes.}
+
+\item{id}{Specify \link{character} id in a \link{vector} format to produce plots for
+specific individuals. Default is the \code{newperson} referring to the predictive
+distribution.}
}
\value{
A \code{\link[base:list]{base::list()}} of \code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} objects producing density
diff --git a/man/plot_jags_effect.Rd b/man/plot_jags_effect.Rd
index 518daa0b..13c7b26e 100644
--- a/man/plot_jags_effect.Rd
+++ b/man/plot_jags_effect.Rd
@@ -8,7 +8,8 @@ plot_jags_effect(
data,
iso = unique(data$Iso_type),
param = unique(data$Parameter),
- strat = unique(data$Stratification)
+ strat = unique(data$Stratification),
+ id = c("newperson")
)
}
\arguments{
@@ -30,6 +31,10 @@ specific parameter, entered with quotes. Options include:
\item{strat}{Specify \link{character} string to produce plots of specific
stratification entered in quotes.}
+
+\item{id}{Specify \link{character} id in a \link{vector} format to produce plots for
+specific individuals. Default is the \code{newperson} referring to the predictive
+distribution.}
}
\value{
A \link{list} of \link[ggplot2:ggplot]{ggplot2::ggplot} objects showing the
diff --git a/man/plot_jags_trace.Rd b/man/plot_jags_trace.Rd
index 355338e8..8f8e6147 100644
--- a/man/plot_jags_trace.Rd
+++ b/man/plot_jags_trace.Rd
@@ -8,7 +8,8 @@ plot_jags_trace(
data,
iso = unique(data$Iso_type),
param = unique(data$Parameter),
- strat = unique(data$Stratification)
+ strat = unique(data$Stratification),
+ id = c("newperson")
)
}
\arguments{
@@ -30,6 +31,10 @@ specific parameter, entered with quotes. Options include:
\item{strat}{Specify \link{character} string to produce plots of specific
stratification entered in quotes.}
+
+\item{id}{Specify \link{character} id in a \link{vector} format to produce plots for
+specific individuals. Default is the \code{newperson} referring to the predictive
+distribution.}
}
\value{
A \link{list} of \link[ggplot2:ggplot]{ggplot2::ggplot} objects producing trace
diff --git a/tests/testthat/_snaps/plot_jags_densitydx/typhoid-plot-ids.svg b/tests/testthat/_snaps/plot_jags_densitydx/typhoid-plot-ids.svg
new file mode 100644
index 00000000..723f4971
--- /dev/null
+++ b/tests/testthat/_snaps/plot_jags_densitydx/typhoid-plot-ids.svg
@@ -0,0 +1,328 @@
+
+
diff --git a/tests/testthat/_snaps/plot_jags_effectivedx/typhoid-plot-ess-ids.svg b/tests/testthat/_snaps/plot_jags_effectivedx/typhoid-plot-ess-ids.svg
new file mode 100644
index 00000000..51d01a16
--- /dev/null
+++ b/tests/testthat/_snaps/plot_jags_effectivedx/typhoid-plot-ess-ids.svg
@@ -0,0 +1,77 @@
+
+
diff --git a/tests/testthat/_snaps/plot_jags_effectivedx/typhoid-plot-ess.svg b/tests/testthat/_snaps/plot_jags_effectivedx/typhoid-plot-ess.svg
index 9bf8b5a7..22b83ba3 100644
--- a/tests/testthat/_snaps/plot_jags_effectivedx/typhoid-plot-ess.svg
+++ b/tests/testthat/_snaps/plot_jags_effectivedx/typhoid-plot-ess.svg
@@ -44,16 +44,16 @@
-
-
+
+alphashapet1
-y1
-y0
+y0
+y1
diff --git a/tests/testthat/_snaps/plot_jags_rhatdx/rhat-typhoid-plot-ids.svg b/tests/testthat/_snaps/plot_jags_rhatdx/rhat-typhoid-plot-ids.svg
new file mode 100644
index 00000000..1de33c5a
--- /dev/null
+++ b/tests/testthat/_snaps/plot_jags_rhatdx/rhat-typhoid-plot-ids.svg
@@ -0,0 +1,81 @@
+
+
diff --git a/tests/testthat/_snaps/plot_jags_tracedx/tracedx-typhoid-plot-ids.svg b/tests/testthat/_snaps/plot_jags_tracedx/tracedx-typhoid-plot-ids.svg
new file mode 100644
index 00000000..cf883d37
--- /dev/null
+++ b/tests/testthat/_snaps/plot_jags_tracedx/tracedx-typhoid-plot-ids.svg
@@ -0,0 +1,343 @@
+
+
diff --git a/tests/testthat/test-plot_jags_densitydx.R b/tests/testthat/test-plot_jags_densitydx.R
index a5e889f2..ab0e48e4 100644
--- a/tests/testthat/test-plot_jags_densitydx.R
+++ b/tests/testthat/test-plot_jags_densitydx.R
@@ -3,8 +3,6 @@ test_that(
desc = "results are consistent with ggplot output",
code = {
skip_if(getRversion() < "4.4.1") # 4.3.3 had issues
- library(runjags)
- library(dplyr)
data <- serodynamics::nepal_sees_jags_output |>
suppressWarnings()
@@ -16,7 +14,28 @@ test_that(
expect_true(is.list(results))
# Test to ensure that a piece of the list is a ggplot object:
- results$typhi$HlyE_IgA |>
+ results$newperson$typhi$HlyE_IgA |>
vdiffr::expect_doppelganger(title = "typhoid_plot")
}
)
+
+test_that(
+ desc = "results are consistent with ggplot output with ids",
+ code = {
+ skip_if(getRversion() < "4.4.1") # 4.3.3 had issues
+
+ data <- serodynamics::nepal_sees_jags_output |>
+ suppressWarnings()
+
+ # Testing for any errors:
+ results <- plot_jags_dens(data, id = c("sees_npl_1", "sees_npl_2")) |>
+ expect_no_error()
+
+ # Test to ensure output is a list object:
+ expect_true(is.list(results))
+
+ # Test to ensure that a piece of the list is a ggplot object:
+ results$sees_npl_1$typhi$HlyE_IgA |>
+ vdiffr::expect_doppelganger(title = "typhoid_plot_ids")
+ }
+)
diff --git a/tests/testthat/test-plot_jags_effectivedx.R b/tests/testthat/test-plot_jags_effectivedx.R
index 844b750b..408f139b 100644
--- a/tests/testthat/test-plot_jags_effectivedx.R
+++ b/tests/testthat/test-plot_jags_effectivedx.R
@@ -14,7 +14,29 @@ test_that(
expect_true(is.list(results))
# Test to ensure that a piece of the list is a ggplot object:
- results$typhi$HlyE_IgA |>
+ results$newperson$typhi$HlyE_IgA |>
vdiffr::expect_doppelganger(title = "typhoid_plot_ESS")
}
)
+
+
+test_that(
+ desc = "results are consistent with ggplot output showing ESS",
+ code = {
+ skip_if(getRversion() < "4.4.1") # 4.3.3 had issues
+
+ data <- serodynamics::nepal_sees_jags_output |>
+ suppressWarnings()
+
+ # Testing for any errors:
+ results <- plot_jags_effect(data, id = c("sees_npl_1", "sees_npl_2")) |>
+ expect_no_error()
+
+ # Test to ensure output is a list object:
+ expect_true(is.list(results))
+
+ # Test to ensure that a piece of the list is a ggplot object:
+ results$sees_npl_1$typhi$HlyE_IgA |>
+ vdiffr::expect_doppelganger(title = "typhoid_plot_ESS_ids")
+ }
+)
diff --git a/tests/testthat/test-plot_jags_rhatdx.R b/tests/testthat/test-plot_jags_rhatdx.R
index 01e9ad0f..94f76203 100644
--- a/tests/testthat/test-plot_jags_rhatdx.R
+++ b/tests/testthat/test-plot_jags_rhatdx.R
@@ -3,18 +3,39 @@ test_that(
desc = "results are consistent with ggplot rhat dotplot output",
code = {
skip_if(getRversion() < "4.4.1") # 4.3.3 had issues
-
+
data <- serodynamics::nepal_sees_jags_output |>
suppressWarnings()
-
+
# Testing for any errors:
results <- plot_jags_Rhat(data) |> expect_no_error()
-
+
# Test to ensure output is a list object:
expect_true(is.list(results))
# Test to ensure that a piece of the list is a ggplot object:
- results$typhi$HlyE_IgA |>
+ results$newperson$typhi$HlyE_IgA |>
vdiffr::expect_doppelganger(title = "rhat_typhoid_plot")
}
)
+
+test_that(
+ desc = "results are consistent with ggplot rhat dotplot output",
+ code = {
+ skip_if(getRversion() < "4.4.1") # 4.3.3 had issues
+
+ data <- serodynamics::nepal_sees_jags_output |>
+ suppressWarnings()
+
+ # Testing for any errors:
+ results <- plot_jags_Rhat(data, id = c("sees_npl_1", "sees_npl_2")) |>
+ expect_no_error()
+
+ # Test to ensure output is a list object:
+ expect_true(is.list(results))
+
+ # Test to ensure that a piece of the list is a ggplot object:
+ results$sees_npl_1$typhi$HlyE_IgA |>
+ vdiffr::expect_doppelganger(title = "rhat_typhoid_plot_ids")
+ }
+)
diff --git a/tests/testthat/test-plot_jags_tracedx.R b/tests/testthat/test-plot_jags_tracedx.R
index d73be318..00217e19 100644
--- a/tests/testthat/test-plot_jags_tracedx.R
+++ b/tests/testthat/test-plot_jags_tracedx.R
@@ -13,6 +13,27 @@ test_that(
# Test to ensure output is a list object
expect_true(is.list(results))
# Test to ensure that a piece of the list is a ggplot object
- vdiffr::expect_doppelganger("tracedx_typhoid_plot", results$typhi$HlyE_IgA)
+ vdiffr::expect_doppelganger("tracedx_typhoid_plot",
+ results$newperson$typhi$HlyE_IgA)
+ }
+)
+
+test_that(
+ desc = "results are consistent with traceplot ggplot output for
+ sees_npl_1 and sees_npl_2",
+ code = {
+ skip_if(getRversion() < "4.4.1") # 4.3.3 had issues
+
+ data <- serodynamics::nepal_sees_jags_output |>
+ suppressWarnings()
+
+ results <- plot_jags_trace(data, id = c("sees_npl_1", "sees_npl_2")) |>
+ # Testing for any errors
+ expect_no_error()
+ # Test to ensure output is a list object
+ expect_true(is.list(results))
+ # Test to ensure that a piece of the list is a ggplot object
+ vdiffr::expect_doppelganger("tracedx_typhoid_plot_ids",
+ results$sees_npl_1$typhi$HlyE_IgA)
}
)