Skip to content

Commit 3a25167

Browse files
committed
register internal s3 methods (doesn't actually export them)
see r-lib/roxygen2#1175
1 parent e4908c2 commit 3a25167

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

NAMESPACE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,31 @@
22

33
S3method("[",neff_ratio)
44
S3method("[",rhat)
5+
S3method(apply_transformations,array)
6+
S3method(apply_transformations,matrix)
7+
S3method(diagnostic_factor,neff_ratio)
8+
S3method(diagnostic_factor,rhat)
59
S3method(log_posterior,CmdStanMCMC)
610
S3method(log_posterior,stanfit)
711
S3method(log_posterior,stanreg)
12+
S3method(melt_mcmc,matrix)
13+
S3method(melt_mcmc,mcmc_array)
814
S3method(neff_ratio,CmdStanMCMC)
915
S3method(neff_ratio,stanfit)
1016
S3method(neff_ratio,stanreg)
17+
S3method(num_chains,data.frame)
18+
S3method(num_chains,mcmc_array)
19+
S3method(num_iters,data.frame)
20+
S3method(num_iters,mcmc_array)
21+
S3method(num_params,data.frame)
22+
S3method(num_params,mcmc_array)
1123
S3method(nuts_params,CmdStanMCMC)
1224
S3method(nuts_params,list)
1325
S3method(nuts_params,stanfit)
1426
S3method(nuts_params,stanreg)
27+
S3method(parameter_names,array)
28+
S3method(parameter_names,default)
29+
S3method(parameter_names,matrix)
1530
S3method(plot,bayesplot_grid)
1631
S3method(plot,bayesplot_scheme)
1732
S3method(pp_check,default)

R/helpers-mcmc.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ select_parameters <-
124124
#' @return A molten data frame.
125125
#'
126126
melt_mcmc <- function(x, ...) UseMethod("melt_mcmc")
127+
128+
#' @export
127129
melt_mcmc.mcmc_array <- function(x,
128130
varnames =
129131
c("Iteration", "Chain", "Parameter"),
@@ -144,6 +146,7 @@ melt_mcmc.mcmc_array <- function(x,
144146
}
145147

146148
# If all chains are already merged
149+
#' @export
147150
melt_mcmc.matrix <- function(x,
148151
varnames = c("Draw", "Parameter"),
149152
value.name = "Value",
@@ -305,13 +308,17 @@ chain_list2array <- function(x) {
305308

306309
# Get parameter names from a 3-D array
307310
parameter_names <- function(x) UseMethod("parameter_names")
311+
312+
#' @export
308313
parameter_names.array <- function(x) {
309314
stopifnot(is_3d_array(x))
310315
dimnames(x)[[3]] %||% abort("No parameter names found.")
311316
}
317+
#' @export
312318
parameter_names.default <- function(x) {
313319
colnames(x) %||% abort("No parameter names found.")
314320
}
321+
#' @export
315322
parameter_names.matrix <- function(x) {
316323
colnames(x) %||% abort("No parameter names found.")
317324
}
@@ -391,6 +398,8 @@ validate_transformations <-
391398
apply_transformations <- function(x, ...) {
392399
UseMethod("apply_transformations")
393400
}
401+
402+
#' @export
394403
apply_transformations.matrix <- function(x, ..., transformations = list()) {
395404
pars <- colnames(x)
396405
x_transforms <- validate_transformations(transformations, pars)
@@ -400,6 +409,8 @@ apply_transformations.matrix <- function(x, ..., transformations = list()) {
400409

401410
x
402411
}
412+
413+
#' @export
403414
apply_transformations.array <- function(x, ..., transformations = list()) {
404415
stopifnot(length(dim(x)) == 3)
405416
pars <- dimnames(x)[[3]]
@@ -437,17 +448,23 @@ num_chains <- function(x, ...) UseMethod("num_chains")
437448
num_iters <- function(x, ...) UseMethod("num_iters")
438449
num_params <- function(x, ...) UseMethod("num_params")
439450

451+
#' @export
440452
num_params.mcmc_array <- function(x, ...) dim(x)[3]
453+
#' @export
441454
num_chains.mcmc_array <- function(x, ...) dim(x)[2]
455+
#' @export
442456
num_iters.mcmc_array <- function(x, ...) dim(x)[1]
457+
#' @export
443458
num_params.data.frame <- function(x, ...) {
444459
stopifnot("Parameter" %in% colnames(x))
445460
length(unique(x$Parameter))
446461
}
462+
#' @export
447463
num_chains.data.frame <- function(x, ...) {
448464
stopifnot("Chain" %in% colnames(x))
449465
length(unique(x$Chain))
450466
}
467+
#' @export
451468
num_iters.data.frame <- function(x, ...) {
452469
cols <- colnames(x)
453470
stopifnot("Iteration" %in% cols || "Draws" %in% cols)

R/mcmc-diagnostics.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,14 @@ diagnostic_factor <- function(x, ...) {
364364
UseMethod("diagnostic_factor")
365365
}
366366

367+
#' @export
367368
diagnostic_factor.rhat <- function(x, ..., breaks = c(1.05, 1.1)) {
368369
cut(x, breaks = c(-Inf, breaks, Inf),
369370
labels = c("low", "ok", "high"),
370371
ordered_result = FALSE)
371372
}
372373

374+
#' @export
373375
diagnostic_factor.neff_ratio <- function(x, ..., breaks = c(0.1, 0.5)) {
374376
cut(x, breaks = c(-Inf, breaks, Inf),
375377
labels = c("low", "ok", "high"),

R/ppc-discrete.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ ppc_bars_data <-
367367
#' @param y,yrep,group User's already validated `y`, `yrep`, and (if applicable)
368368
#' `group` arguments.
369369
#' @param prob,freq User's `prob` and `freq` arguments.
370-
#' @importFrom dplyr "%>%" ungroup count arrange mutate summarise across full_join rename all_of
370+
#' @importFrom dplyr %>% ungroup count arrange mutate summarise across full_join rename all_of
371371
.ppc_bars_data <- function(y, yrep, group = NULL, prob = 0.9, freq = TRUE) {
372372
alpha <- (1 - prob) / 2
373373
probs <- sort(c(alpha, 0.5, 1 - alpha))

0 commit comments

Comments
 (0)