diff --git a/NAMESPACE b/NAMESPACE index 84eb276d..4c4b7e17 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -69,6 +69,7 @@ export(rad2deg) export(rmixture2p) export(rmixture3p) export(rsdm) +export(save_pars) export(sdmSimple) export(set_default_prior) export(softmax) @@ -76,4 +77,5 @@ export(softmaxinv) export(supported_models) export(use_model_template) export(wrap) +importFrom(brms,save_pars) importFrom(magrittr,"%>%") diff --git a/R/bmm-package.R b/R/bmm-package.R index a65cf643..3fd6905c 100644 --- a/R/bmm-package.R +++ b/R/bmm-package.R @@ -2,5 +2,6 @@ "_PACKAGE" ## usethis namespace: start +#' @importFrom brms save_pars ## usethis namespace: end NULL diff --git a/R/utils.R b/R/utils.R index 04248f69..0d15cf4e 100644 --- a/R/utils.R +++ b/R/utils.R @@ -300,4 +300,11 @@ order_data_query <- function(model, data, formula) { data } - +#' @inherit brms::save_pars title params return +#' @description Thin wrapper around [brms::save_pars()]. When calling +#' [fit_model] with additional information to save parameters you can use this +#' function to pass information about saving parameter draws to `brms` without +#' having to load `brms`. Alternatively, you can also load `brms` and call +#' `save_pars`. For details see ?brms::save_pars. +#' @export +save_pars <- brms::save_pars diff --git a/man/save_pars.Rd b/man/save_pars.Rd new file mode 100644 index 00000000..2febb2da --- /dev/null +++ b/man/save_pars.Rd @@ -0,0 +1,43 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{save_pars} +\alias{save_pars} +\title{Control Saving of Parameter Draws} +\usage{ +save_pars(group = TRUE, latent = FALSE, all = FALSE, manual = NULL) +} +\arguments{ +\item{group}{A flag to indicate if group-level coefficients for +each level of the grouping factors should be saved (default is +\code{TRUE}). Set to \code{FALSE} to save memory. Alternatively, +\code{group} may also be a character vector naming the grouping factors +for which to save draws of coefficients.} + +\item{latent}{A flag to indicate if draws of latent variables obtained by +using \code{me} and \code{mi} terms should be saved (default is +\code{FALSE}). Saving these draws allows to better use methods such as +\code{posterior_predict} with the latent variables but leads to very large +\R objects even for models of moderate size and complexity. Alternatively, +\code{latent} may also be a character vector naming the latent variables +for which to save draws.} + +\item{all}{A flag to indicate if draws of all variables defined in Stan's +\code{parameters} block should be saved (default is \code{FALSE}). Saving +these draws is required in order to apply the certain methods such as +\code{bridge_sampler} and \code{bayes_factor}.} + +\item{manual}{A character vector naming Stan variable names which should be +saved. These names should match the variable names inside the Stan code +before renaming. This feature is meant for power users only and will rarely +be useful outside of very special cases.} +} +\value{ +A list of class \code{"save_pars"}. +} +\description{ +Thin wrapper around \code{\link[brms:save_pars]{brms::save_pars()}}. When calling +\link{fit_model} with additional information to save parameters you can use this +function to pass information about saving parameter draws to \code{brms} without +having to load \code{brms}. Alternatively, you can also load \code{brms} and call +\code{save_pars}. For details see ?brms::save_pars. +}