Skip to content

Commit

Permalink
fix examples (#309)
Browse files Browse the repository at this point in the history
* fix examples

* fix vignette

* verbose = FALSE

* remove annoying example

* lints

---------

Co-authored-by: Indrajeet Patil <[email protected]>
  • Loading branch information
strengejacke and IndrajeetPatil authored Oct 8, 2023
1 parent 79b3873 commit ef50b6b
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 39 deletions.
4 changes: 0 additions & 4 deletions R/data_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@
#' x <- hdi(model)
#' plot(x) + theme_modern()
#'
#' data <- rnorm(1000, 1)
#' x <- p_direction(data)
#' plot(x)
#'
#' x <- p_direction(model, verbose = FALSE)
#' plot(x)
#'
Expand Down
14 changes: 7 additions & 7 deletions R/plot.check_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ data_plot.check_outliers <- function(x, data = NULL, rescale_distance = TRUE, ..
d$Id[d$Outliers == "0"] <- NA

method <- switch(attr(x, "method", exact = TRUE),
"cook" = "Cook's Distance",
"pareto" = "Pareto",
"mahalanobis" = "Mahalanobis Distance",
"ics" = "Invariant Coordinate Selection",
"mcd" = "Minimum Covariance Determinant",
"optics" = "OPTICS",
"iforest" = "Isolation Forest",
cook = "Cook's Distance",
pareto = "Pareto",
mahalanobis = "Mahalanobis Distance",
ics = "Invariant Coordinate Selection",
mcd = "Minimum Covariance Determinant",
optics = "OPTICS",
iforest = "Isolation Forest",
"Cook's Distance"
)

Expand Down
2 changes: 1 addition & 1 deletion R/plot.check_outliers_new.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
se = FALSE,
color = colors[1]
) +
scale_colour_manual(values = c("OK" = colors[2], "Influential" = colors[3])) +
scale_colour_manual(values = c(OK = colors[2], Influential = colors[3])) +
(if (isTRUE(show_labels)) {
if (requireNamespace("ggrepel", quietly = TRUE)) {
ggrepel::geom_text_repel(
Expand Down
8 changes: 4 additions & 4 deletions R/plot.compare_performance.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ data_plot.compare_performance <- function(x, data = NULL, ...) {
dataplot$values[dataplot$values > 1] <- 1

attr(dataplot, "info") <- list(
"xlab" = "",
"ylab" = "",
"title" = "Comparison of Model Indices",
"legend_color" = "Models"
xlab = "",
ylab = "",
title = "Comparison of Model Indices",
legend_color = "Models"
)

class(dataplot) <- c("data_plot", "see_compare_performance", "data.frame")
Expand Down
2 changes: 1 addition & 1 deletion R/plot.describe_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ plot.see_parameters_distribution <- function(x,
}

names(highlight_color) <- highlight
highlight_color <- c(highlight_color, "no_highlight" = "grey70")
highlight_color <- c(highlight_color, no_highlight = "grey70")

p <- p +
scale_fill_manual(values = highlight_color) +
Expand Down
12 changes: 6 additions & 6 deletions R/plot.estimate_contrasts.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ data_plot.estimate_contrasts <- function(x, data = NULL, ...) {
dataplot <- .data_contrasts_and_means(x, means, x_name = x_name, y_name = y_name)

attr(dataplot, "info") <- list(
"xlab" = x_name,
"ylab" = y_name,
"title" = paste0("Estimated ", y_name, "s and Contrasts")
xlab = x_name,
ylab = y_name,
title = paste0("Estimated ", y_name, "s and Contrasts")
)

class(dataplot) <- c("data_plot", "see_estimate_contrasts", class(dataplot))
Expand All @@ -45,9 +45,9 @@ data_plot.estimate_contrasts <- function(x, data = NULL, ...) {
polygons <- merge(polygons, data_means[c("Level2", "Mean2")], by = "Level2")

polygons <- rbind(
cbind(polygons, data.frame("x" = polygons$Level1, "y" = polygons$Mean1)),
cbind(polygons, data.frame("x" = polygons$Level2, "y" = polygons$Mean1 - polygons$CI_low)),
cbind(polygons, data.frame("x" = polygons$Level2, "y" = polygons$Mean1 - polygons$CI_high))
cbind(polygons, data.frame(x = polygons$Level1, y = polygons$Mean1)),
cbind(polygons, data.frame(x = polygons$Level2, y = polygons$Mean1 - polygons$CI_low)),
cbind(polygons, data.frame(x = polygons$Level2, y = polygons$Mean1 - polygons$CI_high))
)

list(
Expand Down
10 changes: 5 additions & 5 deletions R/plot.estimate_density.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ data_plot.estimate_density <- function(x,

attr(dataplot, "summary") <- summary
attr(dataplot, "info") <- list(
"xlab" = "Values",
"ylab" = "Density",
"legend_fill" = "Parameter",
"legend_color" = "Parameter",
"title" = "Estimated Density Function"
xlab = "Values",
ylab = "Density",
legend_fill = "Parameter",
legend_color = "Parameter",
title = "Estimated Density Function"
)

class(dataplot) <- c("data_plot", "see_estimate_density", class(dataplot))
Expand Down
8 changes: 4 additions & 4 deletions R/plot.hdi.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ data_plot.bayestestR_eti <- data_plot.hdi
dataplot <- .fix_facet_names(dataplot)

attr(dataplot, "info") <- list(
"xlab" = "Possible parameter values",
"ylab" = ylab,
"legend_fill" = legend_title,
"title" = plot_title
xlab = "Possible parameter values",
ylab = ylab,
legend_fill = legend_title,
title = plot_title
)

class(dataplot) <- c("data_plot", "see_hdi", class(dataplot))
Expand Down
4 changes: 0 additions & 4 deletions man/data_plot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions vignettes/bayestestR.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ theme_set(theme_modern())
```{r}
set.seed(123)
# model with fixed effects only
model <- rstanarm::stan_glm(Sepal.Length ~ Petal.Width * Species, data = iris, refresh = 0)
model <<- rstanarm::stan_glm(Sepal.Length ~ Petal.Width * Species, data = iris, refresh = 0)
# model with fixed and random effects as well as zero-inflation component
model2 <- insight::download_model("brms_zi_3")
model2 <<- insight::download_model("brms_zi_3")
```

## Density Estimation
Expand Down Expand Up @@ -335,7 +335,13 @@ plot(result) +
```

```{r fig.width=11, fig.height=9}
result <- equivalence_test(model2, ci = c(0.89, 0.95), effects = "all", component = "all")
result <- equivalence_test(
model2,
ci = c(0.89, 0.95),
effects = "all",
component = "all",
verbose = FALSE
)
result
Expand Down

0 comments on commit ef50b6b

Please sign in to comment.