Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes bug in compareEstimates with median estimates #39

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions R/smoothArea.R
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ plot.svysae <- function(x, return_list = F, plot.factor = NULL, ...) {
#'
#' @param x svysae object. Plots are created for all models in this object.
#' @param posterior.sample Matrix of posteriors samples of area level quantities with one row for each area and one column for each sample. This argument may be specified to only provide a heatmap for the desired samples.
#' @param title Optional parameter changing the title of the plot
#'
#' @return ggplot containing heat map of pairwise comparisons
#'
Expand All @@ -452,7 +453,8 @@ plot.svysae <- function(x, return_list = F, plot.factor = NULL, ...) {
#' compareEstimates(cts.res)
#' }
compareEstimates <- function(x,
posterior.sample = NULL) {
posterior.sample = NULL,
title = NULL) {


x_att <- attributes(x)
Expand Down Expand Up @@ -488,7 +490,7 @@ compareEstimates <- function(x,
Domain1 = x_att$domain.names[median_order],
Domain2 = "Median",
Prob = NA,
est = domain_medians
est = domain_medians[median_order]

)
extra_cols <- c("", "Median", "Interval")
Expand Down Expand Up @@ -525,9 +527,13 @@ compareEstimates <- function(x,
ggplot2::scale_fill_viridis_c(name = "Probability of Domain 1 > Domain 2",
na.value = "white") +
ggplot2::scale_color_manual(values = c("white", "black"), guide = "none") +
ggplot2::labs(title = x_att$inla.fitted[i],
x = "Domain 2",
ggplot2::labs(x = "Domain 2",
y = "Domain 1")
if (!is.null(title)) {
g_heat <- g_heat + ggplot2::labs(title = title)
} else if (is.null(posterior.sample)) {
g_heat <- g_heat + ggplot2::labs(title = x_att$inla.fitted[i])
}
suppressWarnings(print(g_heat))
}
}
Expand Down
Loading