diff --git a/DESCRIPTION b/DESCRIPTION index 954bc4f46..69a1226f4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -76,4 +76,4 @@ UseLTO: true NeedsCompilation: yes URL: https://mc-stan.org/rstanarm/, https://discourse.mc-stan.org BugReports: https://github.com/stan-dev/rstanarm/issues -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 diff --git a/NAMESPACE b/NAMESPACE index e32585cb3..491beb800 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -229,7 +229,6 @@ importFrom(ggplot2,scale_x_discrete) importFrom(ggplot2,theme) importFrom(ggplot2,theme_bw) importFrom(ggplot2,xlab) -importFrom(reformulas,findbars) importFrom(lme4,fixef) importFrom(lme4,glFormula) importFrom(lme4,glmer) @@ -262,6 +261,7 @@ importFrom(posterior,as_draws_df) importFrom(posterior,as_draws_list) importFrom(posterior,as_draws_matrix) importFrom(posterior,as_draws_rvars) +importFrom(reformulas,findbars) importFrom(rstan,constrain_pars) importFrom(rstan,extract) importFrom(rstan,extract_sparse_parts) diff --git a/R/doc-rstanarm-package.R b/R/doc-rstanarm-package.R index a80773c9c..8d93e769d 100644 --- a/R/doc-rstanarm-package.R +++ b/R/doc-rstanarm-package.R @@ -17,9 +17,6 @@ #' Applied Regression Modeling via RStan #' -#' @docType package -#' @name rstanarm-package -#' @aliases rstanarm #' @useDynLib rstanarm, .registration = TRUE #' #' @import methods @@ -104,4 +101,4 @@ #' @template reference-bayesvis #' @template reference-muth #' -NULL +"_PACKAGE" diff --git a/R/jm_make_assoc_terms.R b/R/jm_make_assoc_terms.R index be823b2f6..91e6fab02 100644 --- a/R/jm_make_assoc_terms.R +++ b/R/jm_make_assoc_terms.R @@ -388,9 +388,11 @@ get_element <- function(parts, m = 1, which = "eta", ...) { # @param grp_assoc Character string, the function to use to collapse # across the lower level units clustered within individuals. # @return A vector or matrix, depending on the method called. +#' @noRd collapse_within_groups <- function(eta, grp_idx, grp_assoc = "sum") { UseMethod("collapse_within_groups") } +#' @exportS3Method NULL collapse_within_groups.default <- function(eta, grp_idx, grp_assoc) { N <- nrow(grp_idx) val <- rep(NA, N) @@ -400,6 +402,7 @@ collapse_within_groups.default <- function(eta, grp_idx, grp_assoc) { } val } +#' @exportS3Method NULL collapse_within_groups.matrix <- function(eta, grp_idx, grp_assoc) { N <- nrow(grp_idx) val <- matrix(NA, nrow = nrow(eta), ncol = N) diff --git a/R/launch_shinystan.R b/R/launch_shinystan.R index f01592c6b..39d6acf05 100644 --- a/R/launch_shinystan.R +++ b/R/launch_shinystan.R @@ -43,7 +43,7 @@ #' used with ShinyStan. The only exception is that ShinyStan does not #' currently support \pkg{rstanarm} models fit using #' \code{algorithm='optimizing'}. See the -#' \pkg{\link[=shinystan-package]{shinystan}} package documentation for more +#' \pkg{\link[shinystan:shinystan-package]{shinystan}} package documentation for more #' information. #' #' @section Faster launch times: diff --git a/R/log_lik.R b/R/log_lik.R index 7d9815d5f..61cff5423 100644 --- a/R/log_lik.R +++ b/R/log_lik.R @@ -200,7 +200,9 @@ ll_fun <- function(x, m = NULL) { # just a single MCMC draw). # @return a named list with elements data, draws, S (posterior sample size) and # N = number of observations +#' @noRd ll_args <- function(object, ...) UseMethod("ll_args") +#' @exportS3Method NULL ll_args.stanreg <- function(object, newdata = NULL, offset = NULL, m = NULL, reloo_or_kfold = FALSE, ...) { validate_stanreg_object(object) @@ -511,6 +513,7 @@ ll_args.stanreg <- function(object, newdata = NULL, offset = NULL, m = NULL, # @param pars Output from extract_pars # @param m Integer specifying which submodel # @param reloo_or_kfold logical. TRUE if ll_args is for reloo or kfold +#' @exportS3Method NULL ll_args.stanjm <- function(object, data, pars, m = 1, reloo_or_kfold = FALSE, ...) { validate_stanjm_object(object) @@ -863,10 +866,12 @@ evaluate_log_basehaz <- function(times, basehaz, coefs) { # at which the log hazard was evaluated for each individual. # @param qwts A vector of unstandardised GK quadrature weights. # @return A vector or matrix of log survival probabilities. +#' @noRd evaluate_log_survival <- function(log_haz, qnodes, qwts) { UseMethod("evaluate_log_survival") } +#' @exportS3Method NULL evaluate_log_survival.default <- function(log_haz, qnodes, qwts) { # convert log hazard to hazard haz <- exp(log_haz) @@ -879,6 +884,7 @@ evaluate_log_survival.default <- function(log_haz, qnodes, qwts) { -cum_haz } +#' @exportS3Method NULL evaluate_log_survival.matrix <- function(log_haz, qnodes, qwts) { # convert log hazard to hazard haz <- exp(log_haz) diff --git a/R/loo-prediction.R b/R/loo-prediction.R index e2c19d38c..41dd59238 100644 --- a/R/loo-prediction.R +++ b/R/loo-prediction.R @@ -155,6 +155,7 @@ loo_predictive_interval.stanreg <- # internal ---------------------------------------------------------------- +#' @exportS3Method NULL psis.stanreg <- function(log_ratios, ...) { object <- log_ratios message("Running PSIS to compute weights...") diff --git a/R/loo.R b/R/loo.R index ff1a88c18..8d1819d6b 100644 --- a/R/loo.R +++ b/R/loo.R @@ -19,7 +19,7 @@ #' #' @description For models fit using MCMC, compute approximate leave-one-out #' cross-validation (LOO, LOOIC) or, less preferably, the Widely Applicable -#' Information Criterion (WAIC) using the \pkg{\link[=loo-package]{loo}} +#' Information Criterion (WAIC) using the \pkg{\link[loo:loo-package]{loo}} #' package. (For \eqn{K}-fold cross-validation see \code{\link{kfold.stanreg}}.) #' Functions for model comparison, and model weighting/averaging are also #' provided. @@ -74,7 +74,7 @@ #' package). #' #' @section Approximate LOO CV: The \code{loo} method for stanreg objects -#' provides an interface to the \pkg{\link[=loo-package]{loo}} package for +#' provides an interface to the \pkg{\link[loo:loo-package]{loo}} package for #' approximate leave-one-out cross-validation (LOO). The LOO Information #' Criterion (LOOIC) has the same purpose as the Akaike Information Criterion #' (AIC) that is used by frequentists. Both are intended to estimate the @@ -96,7 +96,7 @@ #' observations. Warnings about Pareto \eqn{k} estimates indicate observations #' for which the approximation to LOO is problematic (this is described in #' detail in Vehtari, Gelman, and Gabry (2017) and the -#' \pkg{\link[=loo-package]{loo}} package documentation). The +#' \pkg{\link[loo:loo-package]{loo}} package documentation). The #' \code{k_threshold} argument can be used to set the \eqn{k} value above #' which an observation is flagged. If \code{k_threshold} is not \code{NULL} #' and there are \eqn{J} observations with \eqn{k} estimates above diff --git a/R/misc.R b/R/misc.R index 9d59d3fb3..39e7e616a 100644 --- a/R/misc.R +++ b/R/misc.R @@ -545,9 +545,11 @@ set_prior_scale <- function(scale, default, link) { # @param x Predictor matrix. # @param offset Optional offset vector. # @return A vector or matrix. +#' @noRd linear_predictor <- function(beta, x, offset = NULL) { UseMethod("linear_predictor") } +#' @exportS3Method NULL linear_predictor.default <- function(beta, x, offset = NULL) { eta <- as.vector(if (NCOL(x) == 1L) x * beta else x %*% beta) if (length(offset)) @@ -555,6 +557,7 @@ linear_predictor.default <- function(beta, x, offset = NULL) { return(eta) } +#' @exportS3Method NULL linear_predictor.matrix <- function(beta, x, offset = NULL) { if (NCOL(beta) == 1L) beta <- as.matrix(beta) @@ -630,19 +633,24 @@ get_z.stanmvreg <- function(object, m = NULL, ...) { # @param x A stanreg object, family object, or string. # @param ... Other arguments passed to methods. For a \code{stanmvreg} object # this can be an integer \code{m} specifying the submodel. -# @return The inverse link function associated with x. +# @return The inverse link function associated with x +#' @noRd linkinv <- function(x, ...) UseMethod("linkinv") +#' @exportS3Method NULL linkinv.stanreg <- function(x, ...) { if (is(x, "polr")) polr_linkinv(x) else family(x)$linkinv } +#' @exportS3Method NULL linkinv.stanmvreg <- function(x, m = NULL, ...) { ret <- lapply(family(x), `[[`, "linkinv") stub <- get_stub(x) if (!is.null(m)) ret[[m]] else list_nms(ret, stub = stub) } +#' @exportS3Method NULL linkinv.family <- function(x, ...) { x$linkinv } +#' @exportS3Method NULL linkinv.character <- function(x, ...) { stopifnot(length(x) == 1) polr_linkinv(x) diff --git a/R/plots.R b/R/plots.R index a1f8551a8..83be13801 100644 --- a/R/plots.R +++ b/R/plots.R @@ -19,7 +19,7 @@ #' #' The \code{plot} method for \link{stanreg-objects} provides a convenient #' interface to the \link[bayesplot:MCMC-overview]{MCMC} module in the -#' \pkg{\link{bayesplot}} package for plotting MCMC draws and diagnostics. It is also +#' \pkg{\link[bayesplot:bayesplot-package]{bayesplot}} package for plotting MCMC draws and diagnostics. It is also #' straightforward to use the functions from the \pkg{bayesplot} package directly rather than #' via the \code{plot} method. Examples of both methods of plotting are given #' below. diff --git a/R/pp_check.R b/R/pp_check.R index 6e74d0b35..5b3a9fa5f 100644 --- a/R/pp_check.R +++ b/R/pp_check.R @@ -18,7 +18,7 @@ #' Graphical posterior predictive checks #' #' Interface to the \link[bayesplot:PPC-overview]{PPC} (posterior predictive checking) module -#' in the \pkg{\link{bayesplot}} package, providing various plots comparing the +#' in the \pkg{\link[bayesplot:bayesplot-package]{bayesplot}} package, providing various plots comparing the #' observed outcome variable \eqn{y} to simulated datasets \eqn{y^{rep}}{yrep} #' from the posterior predictive distribution. The \code{pp_check} method for #' \link{stanreg-objects} prepares the arguments required for the specified @@ -51,7 +51,7 @@ #' overlay many \code{yrep} datasets (e.g., \code{ppc_dens_overlay}) a larger #' number is used by default, and for other functions (e.g. \code{ppc_stat}) #' the default is to set \code{nreps} equal to the posterior sample size. -#' @param ... Additonal arguments passed to the \pkg{\link{bayesplot}} function +#' @param ... Additonal arguments passed to the \pkg{\link[bayesplot:bayesplot-package]{bayesplot}} function #' called. For many plotting functions \code{...} is optional, however for #' functions that require a \code{group} or \code{x} argument, these arguments #' should be specified in \code{...}. If specifying \code{group} and/or diff --git a/R/predictive_error.R b/R/predictive_error.R index ba9c34364..0567a9940 100644 --- a/R/predictive_error.R +++ b/R/predictive_error.R @@ -141,6 +141,7 @@ predictive_error.ppd <- function(object, y, ...) { # is available. The argument \code{u} specifies the time at which the # prediction error should be calculated (i.e. the time horizon). # +#' @exportS3Method NULL predictive_error.stanmvreg <- function(object, newdataLong = NULL, diff --git a/R/stan_biglm.R b/R/stan_biglm.R index 48f38897e..b9602fccf 100644 --- a/R/stan_biglm.R +++ b/R/stan_biglm.R @@ -52,7 +52,7 @@ #' outcome, such observations do not contribute to these statistics. #' #' @return The output of both \code{stan_biglm} and \code{stan_biglm.fit} is an -#' object of \code{\link[rstan]{stanfit-class}} rather than +#' object of \code{\link[rstan:stanfit-class]{stanfit-class}} rather than #' \code{\link{stanreg-objects}}, which is more limited and less convenient #' but necessitated by the fact that \code{stan_biglm} does not bring the full #' design matrix into memory. Without the full design matrix,some of the diff --git a/R/stan_glm.fit.R b/R/stan_glm.fit.R index 4747a2e3b..2ea9273ea 100644 --- a/R/stan_glm.fit.R +++ b/R/stan_glm.fit.R @@ -902,7 +902,10 @@ pad_reTrms <- function(Ztlist, cnms, flist) { # stats) # @param columns Do the columns (TRUE) or rows (FALSE) correspond to the # variables? + +#' @noRd unpad_reTrms <- function(x, ...) UseMethod("unpad_reTrms") +#' @exportS3Method NULL unpad_reTrms.default <- function(x, ...) { if (is.matrix(x) || is.array(x)) return(unpad_reTrms.array(x, ...)) @@ -910,6 +913,7 @@ unpad_reTrms.default <- function(x, ...) { x[keep] } +#' @exportS3Method NULL unpad_reTrms.array <- function(x, columns = TRUE, ...) { ndim <- length(dim(x)) if (ndim > 3) @@ -943,7 +947,7 @@ make_b_nms <- function(group, m = NULL, stub = "Long") { levels(group$flist[[nm]]))))) } } - return(b_nms) + return(b_nms) } diff --git a/R/stanreg-objects.R b/R/stanreg-objects.R index df78b4cf3..f8fbfbc28 100644 --- a/R/stanreg-objects.R +++ b/R/stanreg-objects.R @@ -84,7 +84,7 @@ #' A list with information about the prior distributions used. #' } #' \item{\code{stanfit,stan_summary}}{ -#' The object of \code{\link[rstan]{stanfit-class}} returned by RStan and a +#' The object of \code{\link[rstan:stanfit-class]{stanfit-class}} returned by RStan and a #' matrix of various summary statistics from the stanfit object. #' } #' \item{\code{rstan_version}}{ diff --git a/R/stanreg_list.R b/R/stanreg_list.R index b4044c36a..fcc59f73b 100644 --- a/R/stanreg_list.R +++ b/R/stanreg_list.R @@ -277,9 +277,11 @@ stanreg_list_families <- function(mods) { # when a stanreg_list is created those attributes should be changed to match # the names of the models used for the stanreg_list in case user has specified # the model_names argument +#' @noRd rename_loos <- function(x,...) UseMethod("rename_loos") # Change model_name attributes of a loo/waic/kfold object stored in a stanreg object, +#' @exportS3Method NULL rename_loos.stanreg <- function(x, new_model_name,...) { for (criterion in c("loo", "waic", "kfold")) { if (!is.null(x[[criterion]])) { @@ -291,6 +293,7 @@ rename_loos.stanreg <- function(x, new_model_name,...) { # Change model_name attributes of loo/waic/kfold objects to correspond to # model names used for stanreg_list +#' @exportS3Method NULL rename_loos.stanreg_list <- function(x, ...) { for (j in seq_along(x)) { x[[j]] <- rename_loos.stanreg(x[[j]], new_model_name = names(x)[j]) diff --git a/man-roxygen/return-stanfit-object.R b/man-roxygen/return-stanfit-object.R index d607b4b8c..60444ede5 100644 --- a/man-roxygen/return-stanfit-object.R +++ b/man-roxygen/return-stanfit-object.R @@ -1,2 +1,2 @@ -#' @return A \link[=stanfit-class]{stanfit} object (or a slightly modified +#' @return A \link[rstan:stanfit-class]{stanfit} object (or a slightly modified #' stanfit object) is returned if \code{<%= fitfun %>} is called directly.