Skip to content

Commit

Permalink
fix issue #956
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-buerkner committed Jul 14, 2020
1 parent 6166a5b commit dc98fee
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 43 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ Additional_repositories:
VignetteBuilder:
knitr,
R.rsp
RoxygenNote: 7.1.0
RoxygenNote: 7.1.1
3 changes: 3 additions & 0 deletions R/log_lik.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#' If \code{pointwise = TRUE}, the output is a function
#' with a \code{draws} attribute containing all relevant
#' data and posterior samples.
#'
#' @template details-newdata-na
#' @template details-allow_new_levels
#'
#' @aliases log_lik
#' @method log_lik brmsfit
Expand Down
6 changes: 2 additions & 4 deletions R/posterior_epred.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
#' categories. In multivariate models, an additional dimension is added to the
#' output which indexes along the different response variables.
#'
#' @details \code{NA} values within factors in \code{newdata},
#' are interpreted as if all dummy variables of this factor are
#' zero. This allows, for instance, to make predictions of the grand mean
#' when using sum coding.
#' @template details-newdata-na
#' @template details-allow_new_levels
#'
#' @examples
#' \dontrun{
Expand Down
39 changes: 18 additions & 21 deletions R/posterior_predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,24 @@
#' @param ... Further arguments passed to \code{\link{prepare_predictions}}
#' that control several aspects of data validation and prediction.
#'
#' @return An \code{array} of predicted response values. If \code{summary =
#' FALSE}, the output is as an S x N matrix, where S is the number of
#' posterior samples and N is the number of observations. In multivariate
#' models, an additional dimension is added to the output which indexes along
#' the different response variables.
#'
#' @details \code{NA} values within factors in \code{newdata},
#' are interpreted as if all dummy variables of this factor are
#' zero. This allows, for instance, to make predictions of the grand mean
#' when using sum coding.
#'
#' For truncated discrete models only: In the absence of any general algorithm
#' to sample from truncated discrete distributions, rejection sampling is
#' applied in this special case. This means that values are sampled until a
#' value lies within the defined truncation boundaries. In practice, this
#' procedure may be rather slow (especially in \R). Thus, we try to do
#' approximate rejection sampling by sampling each value \code{ntrys} times
#' and then select a valid value. If all values are invalid, the closest
#' boundary is used, instead. If there are more than a few of these
#' pathological cases, a warning will occur suggesting to increase argument
#' \code{ntrys}.
#' @return An \code{array} of predicted response values. In univariate models,
#' the output is as an S x N matrix, where S is the number of posterior
#' samples and N is the number of observations. In multivariate models, an
#' additional dimension is added to the output which indexes along the
#' different response variables.
#'
#' @template details-newdata-na
#' @template details-allow_new_levels
#' @details For truncated discrete models only: In the absence of any general
#' algorithm to sample from truncated discrete distributions, rejection
#' sampling is applied in this special case. This means that values are
#' sampled until a value lies within the defined truncation boundaries. In
#' practice, this procedure may be rather slow (especially in \R). Thus, we
#' try to do approximate rejection sampling by sampling each value
#' \code{ntrys} times and then select a valid value. If all values are
#' invalid, the closest boundary is used, instead. If there are more than a
#' few of these pathological cases, a warning will occur suggesting to
#' increase argument \code{ntrys}.
#'
#' @examples
#' \dontrun{
Expand Down
8 changes: 8 additions & 0 deletions man-roxygen/details-allow_new_levels.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#' @details
#' In multilevel models, it is possible to
#' allow new levels of grouping factors to be used in the predictions.
#' This can be controlled via argument \code{allow_new_levels}.
#' New levels can be sampled in multiple ways, which can be controlled
#' via argument \code{sample_new_levels}. Both of these arguments are
#' documented in \code{\link{prepare_predictions}} along with several
#' other useful arguments to control specific aspects of the predictions.
4 changes: 4 additions & 0 deletions man-roxygen/details-newdata-na.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#' @details \code{NA} values within factors in \code{newdata},
#' are interpreted as if all dummy variables of this factor are
#' zero. This allows, for instance, to make predictions of the grand mean
#' when using sum coding.
14 changes: 14 additions & 0 deletions man/log_lik.brmsfit.Rd

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

8 changes: 8 additions & 0 deletions man/posterior_epred.brmsfit.Rd

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

42 changes: 25 additions & 17 deletions man/posterior_predict.brmsfit.Rd

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

0 comments on commit dc98fee

Please sign in to comment.