From 4dfe058e4cc8a695acba659943e994832614c99e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Guti=C3=A9rrez?= Date: Wed, 17 Apr 2024 17:24:18 -0400 Subject: [PATCH] Comment out a dangling function. --- R/predictive_plot_interaction.R | 82 ++++++++++++++++----------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/R/predictive_plot_interaction.R b/R/predictive_plot_interaction.R index 2404b6a..3e7d2bf 100644 --- a/R/predictive_plot_interaction.R +++ b/R/predictive_plot_interaction.R @@ -1,42 +1,42 @@ -#' Plot the posterior predictive pdf (interactions) +#' #' Plot the posterior predictive pdf (interactions) +#' #' +#' #' Plot the posterior predictive pdf for each combination of 2 factors, +#' #' fixing the others at the reference level. +#' #' @param fit An object of class anova_bnp_model. +#' #' @param d1 The 1st factor id. +#' #' @param d2 The 2nd factor id. +#' #' @return A ggplot2 plot. +#' #' @importFrom dplyr mutate filter left_join +#' #' @importFrom dplyr c_across across pull rowwise dense_rank +#' #' @importFrom ggplot2 ggplot aes_string geom_line +#' #' @importFrom rlang := .data +#' #' @export +#' predictive_plot_interaction <- function(fit, d1, d2) { +#' # Get the relevant groups +#' var1 <- paste0("x", d1) +#' var2 <- paste0("x", d2) +#' target_groups <- +#' group_codes(fit) |> +#' mutate(across(-c("group"), ~ dense_rank(.x))) |> +#' mutate(x0 = 1) |> +#' rowwise() |> +#' mutate( +#' touse = max(c_across(-c("group", var1, var2))), +#' touse = .data$touse == 1, +#' touse = .data$touse & (.data[[var1]] == 1 | .data[[var2]] != 1), +#' touse = .data$touse & (.data[[var1]] != 1 | .data[[var2]] == 1) +#' ) |> +#' filter(.data$touse) |> +#' pull("group") #' -#' Plot the posterior predictive pdf for each combination of 2 factors, -#' fixing the others at the reference level. -#' @param fit An object of class anova_bnp_model. -#' @param d1 The 1st factor id. -#' @param d2 The 2nd factor id. -#' @return A ggplot2 plot. -#' @importFrom dplyr mutate filter left_join -#' @importFrom dplyr c_across across pull rowwise dense_rank -#' @importFrom ggplot2 ggplot aes_string geom_line -#' @importFrom rlang := .data -#' @export -predictive_plot_interaction <- function(fit, d1, d2) { - # Get the relevant groups - var1 <- paste0("x", d1) - var2 <- paste0("x", d2) - target_groups <- - group_codes(fit) |> - mutate(across(-c("group"), ~ dense_rank(.x))) |> - mutate(x0 = 1) |> - rowwise() |> - mutate( - touse = max(c_across(-c("group", var1, var2))), - touse = .data$touse == 1, - touse = .data$touse & (.data[[var1]] == 1 | .data[[var2]] != 1), - touse = .data$touse & (.data[[var1]] != 1 | .data[[var2]] == 1) - ) |> - filter(.data$touse) |> - pull("group") - - # Plot the posterior predictive pdf - group_codes(fit) |> - filter(.data$group %in% target_groups) |> - left_join(f_post(fit)) |> - mutate( - {{ var1 }} := factor(.data[[var1]]), - {{ var2 }} := factor(.data[[var2]]) - ) |> - ggplot(aes_string(x = "y",y = "f", color = paste0(var1, ":", var2))) + - geom_line() -} +#' # Plot the posterior predictive pdf +#' group_codes(fit) |> +#' filter(.data$group %in% target_groups) |> +#' left_join(f_post(fit)) |> +#' mutate( +#' {{ var1 }} := factor(.data[[var1]]), +#' {{ var2 }} := factor(.data[[var2]]) +#' ) |> +#' ggplot(aes_string(x = "y",y = "f", color = paste0(var1, ":", var2))) + +#' geom_line() +#' }