
Last chance! 50% off unlimited learning
Sale ends in
brmsfit
Objectsfitted
method. This is because the measurement error is incorporated.
The estimated means of both methods should, however, be very similar.## S3 method for class 'brmsfit':
predict(object, newdata = NULL, re_formula = NULL,
transform = NULL, allow_new_levels = FALSE, subset = NULL,
nsamples = NULL, ntrys = 5, summary = TRUE, probs = c(0.025, 0.975),
...)
brmsfit
NULL
(default), the orginal data of the model is used.NULL
(default), include all random effects;
if NA
, include no random effects.FALSE
).
Only relevant if newdata
is provided.NULL
(the default), all samples are used.NULL
(the default) all samples are used.
Ignored if subset
is not NULL
.5
). See Details for more information.TRUE
.quantile
function.
Only used if summary
is TRUE
.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 + (1+age||patient),
data = kidney, family = "exponential", inits = "0")
## predicted responses
pp <- predict(fit)
head(pp)
## predicted responses excluding the random effect of age
pp2 <- predict(fit, re_formula = ~ (1|patient))
head(pp2)
## predicted responses of patient 1 for new data
newdata <- data.frame(sex = factor(c("male", "female")),
age = c(20, 50),
patient = c(1, 1))
predict(fit, newdata = newdata)
Run the code above in your browser using DataLab