brmsfit
Objects## S3 method for class 'brmsfit':
predict(object, newdata = NULL, re_formula = NULL,
transform = NULL, allow_new_levels = FALSE, summary = TRUE,
probs = c(0.025, 0.975), ntrys = 5, ...)
brmsfit
NULL
(default), the data used to fit the model is applied.NULL
(default), include all random effects; if NA
, include no random effects.
Other options will be implemented in the future.FALSE
(no new levels allowed) is the only option.
This will change in future versions of the package.TRUE
quantile
function.
Only used if summary
is TRUE
.5
). See Details for more information.summary = TRUE
the output depends on the family:
For catagorical and ordinal families, it is a N x C matrix where N is the number of observations and
C is the number of categories. For all other families, it is a N x E matrix where E is equal
to length(probs) + 2
.
If summary = FALSE
, the output is as a S x N matrix, where S is the number of samples.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 occure suggesting to increase argument ntrys
.
For models fitted with newdata with factors in fixed or random effects.
The predicted results are only valid if all factor levels present in the initial
data are also defined and ordered correctly for the factors in newdata
.
Grouping factors may contain fewer levels than in the inital data without causing problems.
When using higher versions of brms , all factors are automatically checked
for correctness and amended if necessary.=>
## fit a model
fit <- brm(time | cens(censored) ~ age + sex, data = kidney,
family = "exponential", silent = TRUE)
## posterior predictive checks
pp <- predict(fit)
head(pp)
## predict response for new data
newdata <- data.frame(sex = factor(c("male", "female")),
age = c(20,50))
predict(fit, newdata = newdata)
Run the code above in your browser using DataLab