Skip to content

Commit 929ceec

Browse files
committed
minor cleaning and regenerate Rds
1 parent a947141 commit 929ceec

23 files changed

+128
-109
lines changed

R/mcmc-combo.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ NULL
6666
mcmc_combo <-
6767
function(x,
6868
combo = c("dens", "trace"),
69+
...,
6970
widths = NULL,
70-
gg_theme = NULL,
71-
...) {
71+
gg_theme = NULL) {
7272
suggested_package("gridExtra")
7373

7474
if (length(combo) < 2) {

R/mcmc-diagnostics-nuts.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ validate_enough_chains <- function(chain = NULL, n_chain) {
506506
}
507507

508508
#' @param x data frame with nuts params
509-
#' @param lp data frame with lp__
509+
#' @param lp data frame with `lp__`
510510
#' @noRd
511511
validate_nuts_data_frame <- function(x, lp) {
512512
if (!is.data.frame(x)) {

R/mcmc-diagnostics.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ mcmc_acf <-
308308
function(x,
309309
pars = character(),
310310
regex_pars = character(),
311-
facet_args = list(),
312311
...,
312+
facet_args = list(),
313313
lags = 20,
314314
size = NULL) {
315315
check_ignored_arguments(...)
@@ -330,8 +330,8 @@ mcmc_acf_bar <-
330330
function(x,
331331
pars = character(),
332332
regex_pars = character(),
333-
facet_args = list(),
334333
...,
334+
facet_args = list(),
335335
lags = 20) {
336336
check_ignored_arguments(...)
337337
.mcmc_acf(

R/mcmc-distributions.R

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ mcmc_hist <- function(x,
109109
pars = character(),
110110
regex_pars = character(),
111111
transformations = list(),
112-
facet_args = list(),
113112
...,
113+
facet_args = list(),
114114
binwidth = NULL,
115115
breaks = NULL,
116116
freq = TRUE) {
@@ -135,8 +135,8 @@ mcmc_dens <- function(x,
135135
pars = character(),
136136
regex_pars = character(),
137137
transformations = list(),
138-
facet_args = list(),
139138
...,
139+
facet_args = list(),
140140
trim = FALSE) {
141141
check_ignored_arguments(...)
142142
.mcmc_dens(
@@ -158,8 +158,8 @@ mcmc_hist_by_chain <- function(x,
158158
pars = character(),
159159
regex_pars = character(),
160160
transformations = list(),
161-
facet_args = list(),
162161
...,
162+
facet_args = list(),
163163
binwidth = NULL,
164164
freq = TRUE) {
165165
check_ignored_arguments(...)
@@ -182,9 +182,9 @@ mcmc_dens_overlay <- function(x,
182182
pars = character(),
183183
regex_pars = character(),
184184
transformations = list(),
185+
...,
185186
facet_args = list(),
186187
color_chains = TRUE,
187-
...,
188188
trim = FALSE) {
189189
check_ignored_arguments(...)
190190
.mcmc_dens(
@@ -204,10 +204,12 @@ mcmc_dens_overlay <- function(x,
204204
#' @template args-density-controls
205205
#' @param color_chains Option for whether to separately color chains.
206206
#' @export
207-
mcmc_dens_chains <- function(x, pars = character(), regex_pars = character(),
207+
mcmc_dens_chains <- function(x,
208+
pars = character(),
209+
regex_pars = character(),
208210
transformations = list(),
209-
color_chains = TRUE,
210211
...,
212+
color_chains = TRUE,
211213
bw = NULL, adjust = NULL, kernel = NULL,
212214
n_dens = NULL) {
213215
check_ignored_arguments(...)
@@ -252,7 +254,8 @@ mcmc_dens_chains <- function(x, pars = character(), regex_pars = character(),
252254

253255
#' @rdname MCMC-distributions
254256
#' @export
255-
mcmc_dens_chains_data <- function(x, pars = character(),
257+
mcmc_dens_chains_data <- function(x,
258+
pars = character(),
256259
regex_pars = character(),
257260
transformations = list(),
258261
...,
@@ -280,8 +283,8 @@ mcmc_violin <- function(x,
280283
pars = character(),
281284
regex_pars = character(),
282285
transformations = list(),
283-
facet_args = list(),
284286
...,
287+
facet_args = list(),
285288
probs = c(0.1, 0.5, 0.9)) {
286289
check_ignored_arguments(...)
287290
.mcmc_dens(
@@ -298,10 +301,6 @@ mcmc_violin <- function(x,
298301

299302

300303

301-
302-
303-
304-
305304
# internal -----------------------------------------------------------------
306305
.mcmc_hist <- function(x,
307306
pars = character(),
@@ -330,8 +329,7 @@ mcmc_violin <- function(x,
330329
breaks = breaks
331330
)
332331

333-
if (is.null(facet_args[["scales"]]))
334-
facet_args[["scales"]] <- "free"
332+
facet_args[["scales"]] <- facet_args[["scales"]] %||% "free"
335333
if (!by_chain) {
336334
if (n_param > 1) {
337335
facet_args[["facets"]] <- ~ Parameter
@@ -432,8 +430,7 @@ mcmc_violin <- function(x,
432430
y = if (violin) levels(data$Parameter) else NULL)
433431
} else {
434432
facet_args[["facets"]] <- ~ Parameter
435-
if (is.null(facet_args[["scales"]]))
436-
facet_args[["scales"]] <- "free"
433+
facet_args[["scales"]] <- facet_args[["scales"]] %||% "free"
437434
graph <- graph + do.call("facet_wrap", facet_args)
438435
}
439436

R/mcmc-intervals.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,8 @@ mcmc_areas_ridges_data <- function(x,
691691
...,
692692
prob_outer = 1,
693693
prob = 1,
694-
bw = NULL, adjust = NULL, kernel = NULL,
694+
bw = NULL,
695+
adjust = NULL, kernel = NULL,
695696
n_dens = NULL) {
696697
check_ignored_arguments(...)
697698
mcmc_areas_data(x, pars = pars, regex_pars = regex_pars,

R/mcmc-parcoord.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
#' mcmc_parcoord(draws, size = 0.25, alpha = 0.1,
8181
#' np = np, np_style = div_style)
8282
#'
83-
#' # to use a transformation (e.g., to standarde all the variables)
83+
#' # to use a transformation (e.g., standardizing all the variables can be helpful)
8484
#' # specify the 'transformations' argument (though partial argument name
8585
#' # matching means we can just use 'trans' or 'transform')
8686
#' mcmc_parcoord(

R/mcmc-recover.R

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ mcmc_recover_intervals <-
100100
function(x,
101101
true,
102102
batch = rep(1, length(true)),
103-
facet_args = list(),
104103
...,
104+
facet_args = list(),
105105
prob = 0.5,
106106
prob_outer = 0.9,
107107
point_est = c("median", "mean", "none"),
@@ -121,8 +121,9 @@ mcmc_recover_intervals <-
121121
)
122122
all_separate <- length(unique(batch)) == length(true)
123123
point_est <- match.arg(point_est)
124-
if (point_est == "none")
124+
if (point_est == "none") {
125125
point_est <- NULL
126+
}
126127

127128
alpha1 <- (1 - prob) / 2
128129
alpha2 <- (1 - prob_outer) / 2
@@ -143,11 +144,9 @@ mcmc_recover_intervals <-
143144
factor(rownames(intervals),
144145
levels = rownames(intervals)[as.integer(as.factor(batch))])
145146
}
146-
facet_args[["facets"]] <- ~ Batch
147-
if (is.null(facet_args[["strip.position"]]))
148-
facet_args[["strip.position"]] <- "top"
149-
if (is.null(facet_args[["scales"]]))
150-
facet_args[["scales"]] <- "free"
147+
facet_args[["facets"]] <- "Batch"
148+
facet_args[["strip.position"]] <- facet_args[["strip.position"]] %||% "top"
149+
facet_args[["scales"]] <- facet_args[["scales"]] %||% "free"
151150

152151
plot_caption <- paste0("Showing ", round(prob * 100, 1), "% and ",
153152
round(prob_outer * 100, 1), "% intervals")
@@ -165,13 +164,14 @@ mcmc_recover_intervals <-
165164
) +
166165
bayesplot_theme_get()
167166

168-
if (!is.null(point_est))
167+
if (!is.null(point_est)) {
169168
graph <- graph +
170169
geom_point(
171170
aes_(y = ~ Point, shape = "Estimated",
172171
color = "Estimated", fill = "Estimated"),
173172
size = size
174173
)
174+
}
175175

176176
graph <- graph +
177177
geom_point(
@@ -199,13 +199,14 @@ mcmc_recover_intervals <-
199199
xaxis_title(FALSE) +
200200
yaxis_title(FALSE)
201201

202-
if (all_separate)
202+
if (all_separate) {
203203
return(
204204
graph +
205205
theme(axis.line.x = element_blank()) +
206206
xaxis_ticks(FALSE) +
207207
xaxis_text(FALSE)
208208
)
209+
}
209210

210211
graph +
211212
xaxis_text(face = "bold") +
@@ -219,8 +220,8 @@ mcmc_recover_scatter <-
219220
function(x,
220221
true,
221222
batch = rep(1, length(true)),
222-
facet_args = list(),
223223
...,
224+
facet_args = list(),
224225
point_est = c("median", "mean"),
225226
size = 3,
226227
alpha = 1) {
@@ -299,8 +300,8 @@ mcmc_recover_scatter <-
299300
mcmc_recover_hist <-
300301
function(x,
301302
true,
302-
facet_args = list(),
303303
...,
304+
facet_args = list(),
304305
binwidth = NULL,
305306
breaks = NULL) {
306307

@@ -315,9 +316,8 @@ mcmc_recover_hist <-
315316
vline_data <- data.frame(Parameter = colnames(x), True = true)
316317
hist_data <- melt_mcmc(x)[, -1]
317318

318-
facet_args[["facets"]] <- ~ Parameter
319-
if (is.null(facet_args[["scales"]]))
320-
facet_args[["scales"]] <- "free"
319+
facet_args[["facets"]] <- "Parameter"
320+
facet_args[["scales"]] <- facet_args[["scales"]] %||% "free"
321321

322322
ggplot() +
323323
geom_histogram(

R/mcmc-scatterplots.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,9 @@ pairs_condition <- function(chains = NULL, draws = NULL, nuts = NULL) {
721721

722722
# internal for mcmc_pairs -------------------------------------------------
723723

724-
#' Get plotting functions from user-specified `diag_fun`, `off_diag_fun` arguments
724+
#' Get plotting functions from user-specified
725+
#' `diag_fun` and `off_diag_fun` arguments
726+
#'
725727
#' @noRd
726728
#' @param x User specified `diag_fun` or `off_diag_fun` argument to `mcmc_pairs()`
727729
pairs_plotfun <- function(x) {
@@ -733,7 +735,7 @@ pairs_plotfun <- function(x) {
733735
#'
734736
#' @noRd
735737
#' @param df A data frame (from `nuts_params()`, `log_posterior()`, etc)
736-
#' @param .form Same as 'form' arg to `utils::unstack()`
738+
#' @param .form Same as `form` arg to `utils::unstack()`
737739
unstack_to_matrix <- function(df, .form) {
738740
x <- utils::unstack(df, form = .form)
739741
as.matrix(x)

R/mcmc-traces.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ mcmc_trace <-
164164
pars = character(),
165165
regex_pars = character(),
166166
transformations = list(),
167-
facet_args = list(),
168167
...,
168+
facet_args = list(),
169169
n_warmup = 0,
170170
iter1 = 0,
171171
window = NULL,
@@ -216,8 +216,8 @@ mcmc_trace_highlight <- function(x,
216216
pars = character(),
217217
regex_pars = character(),
218218
transformations = list(),
219-
facet_args = list(),
220219
...,
220+
facet_args = list(),
221221
n_warmup = 0,
222222
window = NULL,
223223
size = NULL,
@@ -342,8 +342,8 @@ mcmc_rank_hist <- function(x,
342342
pars = character(),
343343
regex_pars = character(),
344344
transformations = list(),
345-
facet_args = list(),
346345
...,
346+
facet_args = list(),
347347
n_bins = 20,
348348
ref_line = FALSE) {
349349
check_ignored_arguments(...)

R/ppc-discrete.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ ppc_bars_grouped <-
141141
function(y,
142142
yrep,
143143
group,
144-
facet_args = list(),
145144
...,
145+
facet_args = list(),
146146
prob = 0.9,
147147
width = 0.9,
148148
size = 1,

0 commit comments

Comments
 (0)