Skip to content

Commit

Permalink
CRAN v1.3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
florale committed Jun 30, 2024
1 parent 32090f1 commit 5216f9e
Show file tree
Hide file tree
Showing 34 changed files with 72 additions and 72 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: multilevelcoda
Type: Package
Title: Estimate Bayesian Multilevel Models for Compositional Data
Version: 1.3.0
Date: 2024-6-10
Version: 1.3.0.1
Date: 2024-6-13
Authors@R:
c(person(given = "Flora",
family = "Le",
Expand Down
2 changes: 1 addition & 1 deletion R/brmcoda-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ neff_ratio.brmcoda <- function(object, ...) {
#'
#' @param x1 A \code{brmcoda} object.
#' @param x2 Another \code{brmcoda} object based on the same responses.
#' @param ... Other arguments passed to \code{\link{bayes_factor.brmsfit}}.
#' @param ... Other arguments passed to \code{\link[brms:bayes_factor.brmsfit]{bayes_factor.brmsfit}}.
#'
#' @importFrom brms bayes_factor
#' @method bayes_factor brmcoda
Expand Down
4 changes: 2 additions & 2 deletions R/brmcoda.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#'
#' @param formula A object of class \code{formula}, \code{brmsformula}:
#' A symbolic description of the model to be fitted.
#' Details of the model specification can be found in \code{\link{brmsformula}}.
#' Details of the model specification can be found in \code{\link[brms:brmsformula]{brmsformula}}.
#' @param complr A \code{\link{complr}} object containing data of composition,
#' ILR coordinates, and other variables used in the model.
#' @param ... Further arguments passed to \code{\link{brm}}.
#' @param ... Further arguments passed to \code{\link[brms:brm]{brm}}.
#'
#' @return A \code{\link{brmcoda}} with two elements
#' \item{\code{complr}}{ An object of class \code{complr} used in the \code{brm} model. }
Expand Down
22 changes: 11 additions & 11 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' that were reallocated to in the model.
#' @param ref A character value of ((\code{"grandmean"} or \code{"clustermean"} or \code{"users"}),
#' @param level A character value of (\code{"between"}, \code{"within"}), or \code{"aggregate"}).
#' @param ... Further arguments passed to \code{\link{ggplot}}.
#' @param ... Further components to the plot, followed by a plus sign (+).
#'
#' @return A ggplot graph object showing the estimated difference in outcome when
#' each pair of compositional variables are substituted for a specific time.
Expand Down Expand Up @@ -86,7 +86,7 @@ plot.substitution <- function(x, to,
#' Make a plot of \code{brmcoda} model results.
#'
#' @param x A \code{\link{brmcoda}} class object.
#' @param ... Further arguments passed to \code{\link{plot.brmsfit}}.
#' @param ... Further arguments passed to \code{\link[brms:plot.brmsfit]{plot.brmsfit}}.
#'
#' @inherit brms::plot.brmsfit return
#'
Expand All @@ -96,11 +96,11 @@ plot.substitution <- function(x, to,
#' @export
#' @examples
#' \dontrun{
#' cilr <- compilr(data = mcompd, sbp = sbp,
#' cilr <- complr(data = mcompd, sbp = sbp,
#' parts = c("TST", "WAKE", "MVPA", "LPA", "SB"), idvar = "ID")
#'
#' # model with compositional predictor at between and within-person levels
#' fit <- brmcoda(compilr = cilr,
#' fit <- brmcoda(complr = cilr,
#' formula = Stress ~ bilr1 + bilr2 + bilr3 + bilr4 +
#' wilr1 + wilr2 + wilr3 + wilr4 + (1 | ID),
#' chain = 1, iter = 500)
Expand All @@ -110,13 +110,13 @@ plot.brmcoda <- function(x, ...) {
plot(x$model, ...)
}

#' Create a matrix of output plots from a \code{\link{brmcoda}}'s \code{\link{brmsfit}} object
#' Create a matrix of output plots from a \code{\link{brmcoda}}'s \code{\link[brms:brmsfit]{brmsfit}} object
#'
#' A \code{\link[graphics:pairs]{pairs}}
#' method that is customized for MCMC output.
#'
#' @param x A \code{brmcoda} class object.
#' @param ... Further arguments passed to \code{\link{pairs.brmsfit}}.
#' @param ... Further arguments passed to \code{\link[brms:pairs.brmsfit]{pairs.brmsfit}}.
#'
#' @inherit brms::pairs.brmsfit return
#'
Expand All @@ -127,11 +127,11 @@ plot.brmcoda <- function(x, ...) {
#' @export
#' @examples
#' \dontrun{
#' cilr <- compilr(data = mcompd, sbp = sbp,
#' cilr <- complr(data = mcompd, sbp = sbp,
#' parts = c("TST", "WAKE", "MVPA", "LPA", "SB"), idvar = "ID")
#'
#' # model with compositional predictor at between and within-person levels
#' fit <- brmcoda(compilr = cilr,
#' fit <- brmcoda(complr = cilr,
#' formula = Stress ~ bilr1 + bilr2 + bilr3 + bilr4 +
#' wilr1 + wilr2 + wilr3 + wilr4 + (1 | ID),
#' chain = 1, iter = 500)
Expand All @@ -147,7 +147,7 @@ pairs.brmcoda <- function(x, ...) {
#' implemented in the \pkg{bayesplot} package.
#'
#' @param object A \code{brmcoda} class object.
#' @param ... Further arguments passed to \code{\link{mcmc_plot.brmsfit}}.
#' @param ... Further arguments passed to \code{\link[brms:mcmc_plot.brmsfit]{mcmc_plot.brmsfit}}.
#'
#' @inherit brms::mcmc_plot.brmsfit return
#'
Expand All @@ -159,11 +159,11 @@ pairs.brmcoda <- function(x, ...) {
#' @export
#' @examples
#' \dontrun{
#' cilr <- compilr(data = mcompd, sbp = sbp,
#' cilr <- complr(data = mcompd, sbp = sbp,
#' parts = c("TST", "WAKE", "MVPA", "LPA", "SB"), idvar = "ID")
#'
#' # model with compositional predictor at between and within-person levels
#' fit <- brmcoda(compilr = cilr,
#' fit <- brmcoda(complr = cilr,
#' formula = Stress ~ bilr1 + bilr2 + bilr3 + bilr4 +
#' wilr1 + wilr2 + wilr3 + wilr4 + (1 | ID),
#' chain = 1, iter = 500)
Expand Down
30 changes: 13 additions & 17 deletions R/posterior.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' results are returned on the log-ratio scale.
#' If \code{"response"}, results are returned on the compositional scale
#' of the response variable.
#' @param ... Further arguments passed to \code{\link{predict.brmsfit}}
#' @param ... Further arguments passed to \code{\link[brms:predict.brmsfit]{predict.brmsfit}}
#' that control additional aspects of prediction.
#' @inheritParams brms::predict.brmsfit
#'
Expand Down Expand Up @@ -68,19 +68,17 @@ predict.brmcoda <- function(object,

if (inherits(object$model$formula, "mvbrmsformula")) {
if ((length(grep("ilr", object$model$formula$responses, value = T)) > 0)) {
if (scale == "linear") {
warning(sprintf(
if (isFALSE(scale == "response")) {
warning(sprintf(
"This is a mvbrmsformula model, it is recommended to
set scale = \"response\" to return results on compsitional scale."))

out <- predict(
object$model,
scale = scale,
summary = summary,
...
)
}
if (scale == "response") {
} else {
out <- predict(
object$model,
summary = FALSE,
Expand Down Expand Up @@ -126,7 +124,7 @@ predict.brmcoda <- function(object,
#' @aliases fitted
#'
#' @inheritParams predict.brmcoda
#' @param ... Further arguments passed to \code{\link{fitted.brmsfit}}
#' @param ... Further arguments passed to \code{\link[brms:fitted.brmsfit]{fitted.brmsfit}}
#' that control additional aspects of prediction.
#'
#' @inherit brms::fitted.brmsfit return
Expand Down Expand Up @@ -177,19 +175,17 @@ fitted.brmcoda <- function(object,

if (inherits(object$model$formula, "mvbrmsformula")) {
if ((length(grep("ilr", object$model$formula$responses, value = T)) > 0)) {
if (scale == "linear") {
if (isFALSE(scale == "response")) {
warning(sprintf(
"This is a mvbrmsformula model, it is recommended to
set scale = \"response\" to return results on compsitional scale."))

out <- fitted(
object$model,
scale = scale,
summary = summary,
...
)
}
if (scale == "response") {
} else {
out <- fitted(
object$model,
summary = FALSE,
Expand Down Expand Up @@ -227,7 +223,7 @@ fitted.brmcoda <- function(object,
#' @aliases fixef
#'
#' @param object An object of class \code{brmcoda}.
#' @param ... Further arguments passed to \code{\link{fixef.brmsfit}}.
#' @param ... Further arguments passed to \code{\link[brms:fixef.brmsfit]{fixef.brmsfit}}.
#'
#' @inherit brms::fixef.brmsfit return
#'
Expand Down Expand Up @@ -265,7 +261,7 @@ fixef.brmcoda <- function(object, ...) {
#' of the \code{brmsfit} object in a \code{brmcoda} object.
#'
#' @inheritParams fixef.brmcoda
#' @param ... Further arguments passed to \code{\link{vcov.brmsfit}}.
#' @param ... Further arguments passed to \code{\link[brms:vcov.brmsfit]{vcov.brmsfit}}.
#'
#' @inherit brms::vcov.brmsfit return
#'
Expand Down Expand Up @@ -301,7 +297,7 @@ vcov.brmcoda <- function(object, ...) {
#' @aliases ranef
#'
#' @inheritParams fixef.brmcoda
#' @param ... Further arguments passed to \code{\link{ranef.brmsfit}}.
#' @param ... Further arguments passed to \code{\link[brms:ranef.brmsfit]{ranef.brmsfit}}.
#'
#' @inherit brms::ranef.brmsfit return
#'
Expand Down Expand Up @@ -340,7 +336,7 @@ ranef.brmcoda <- function(object, ...) {
#' @aliases coef
#'
#' @inheritParams fixef.brmcoda
#' @param ... Further arguments passed to \code{\link{coef.brmsfit}}.
#' @param ... Further arguments passed to \code{\link[brms:coef.brmsfit]{coef.brmsfit}}.
#'
#' @inherit brms::coef.brmsfit return
#'
Expand Down Expand Up @@ -382,7 +378,7 @@ coef.brmcoda <- function(object, ...) {
#' @aliases VarCorr
#'
#' @param x An object of class \code{brmcoda}.
#' @param ... Further arguments passed to \code{\link{VarCorr.brmsfit}}.
#' @param ... Further arguments passed to \code{\link[brms:VarCorr.brmsfit]{VarCorr.brmsfit}}.
#'
#' @inherit brms::VarCorr.brmsfit return
#'
Expand Down Expand Up @@ -416,7 +412,7 @@ VarCorr.brmcoda <- function(x, ...) {
#' Compute posterior draws of residuals/predictive errors
#'
#' @inheritParams fixef.brmcoda
#' @param ... Further arguments passed to \code{\link{residuals.brmsfit}}.
#' @param ... Further arguments passed to \code{\link[brms:residuals.brmsfit]{residuals.brmsfit}}.
#' @inherit brms::residuals.brmsfit return
#'
#' @seealso \code{\link[brms:residuals.brmsfit]{residuals.brmsfit}}
Expand Down
3 changes: 2 additions & 1 deletion R/shiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#'
#' @param object A fitted model object of class \code{brmcoda}.
#' @param ... Optional arguments to pass to
#' \code{\link{launch_shinystan.brmsfit}} or \code{\link[shiny:runApp]{runApp}}.
#' \code{\link[shinystan:launch_shinystan]{launch_shinystan}} or
#' \code{\link[shiny:runApp]{runApp}}.
#'
#' @seealso \code{\link[shinystan:launch_shinystan]{launch_shinystan}}
#'
Expand Down
2 changes: 1 addition & 1 deletion R/substitution-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ build.rg <- function(object,
# factors = factors,
# length = NA))
drg <- as.data.table(insight::get_datagrid(model.frame(object),
at = paste0(resp),
# at = paste0(resp),
factors = factors,
length = NA))

Expand Down
2 changes: 1 addition & 1 deletion R/substitution.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#' If \code{"response"}, results are returned on the scale of the response variable.
#' If \code{"linear"}, results are returned on the scale of the linear predictor term,
#' that is without applying the inverse link function or other transformations.
#' @param ... Additional arguments passed to \code{\link{describe_posterior}}.
#' @param ... currently ignored.
#'
#' @return A list containing the results of multilevel compositional substitution model.
#' The first six lists contain the results of the substitution estimation for a compositional part.
Expand Down
2 changes: 1 addition & 1 deletion R/summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ print.complr <- function(x, ...) {
#' Create a Summary of a fitted \code{brmsfit} model in a \code{brmcoda} object
#'
#' @param object An object of class \code{brmcoda}.
#' @param ... Other arguments passed to \code{\link{summary.brmsfit}}.
#' @param ... Other arguments passed to \code{\link[brms:summary.brmsfit]{summary.brmsfit}}.
#'
#' @method summary brmcoda
#'
Expand Down
5 changes: 3 additions & 2 deletions R/update.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ update.complr <- function(object, newdata, ...) {
#' This method allows for updating an existing \code{\link{brmcoda}} object.
#'
#' @param object A fitted \code{\link{brmcoda}} object to be updated.
#' @param formula. Changes to the formula; for details see \code{\link{update.formula}} and \code{\link{brmsformula}}.
#' @param formula. Changes to the formula; for details see
#' \code{\link[stats:update.formula]{update.formula}} and \code{\link[brms:brmsformula]{brmsformula}}.
#' @param newcomplr A \code{\link{complr}} object containing data of composition,
#' ILR coordinates, and other variables used in the updated model.
#' @param newdata A \code{data.frame} or \code{data.table}
#' containing data of all variables used in the analysis.
#' It must include a composition and the same ID variable as the existing \code{\link{complr}} object.
#' @param ... Further arguments passed to \code{\link{brm}}.
#' @param ... Further arguments passed to \code{\link[brms:brm]{brm}}.
#'
#' @inherit brmcoda return
#'
Expand Down
2 changes: 1 addition & 1 deletion man/VarCorr.brmcoda.Rd

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

2 changes: 1 addition & 1 deletion man/bayes_factor.brmcoda.Rd

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

4 changes: 2 additions & 2 deletions man/brmcoda.Rd

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

2 changes: 1 addition & 1 deletion man/bsub.Rd

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

2 changes: 1 addition & 1 deletion man/bsubmargins.Rd

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

2 changes: 1 addition & 1 deletion man/coef.brmcoda.Rd

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

2 changes: 1 addition & 1 deletion man/fitted.brmcoda.Rd

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

2 changes: 1 addition & 1 deletion man/fixef.brmcoda.Rd

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

3 changes: 2 additions & 1 deletion man/launch_shinystan.brmcoda.Rd

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

6 changes: 3 additions & 3 deletions man/mcmc_plot.brmcoda.Rd

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

Loading

0 comments on commit 5216f9e

Please sign in to comment.