brmsfit
Objectspredict
method.
This is because the measurement error is not incorporated.
The estimated means of both methods should, however, be very similar.
"fitted"(object, newdata = NULL, re_formula = NULL, scale = c("response", "linear"), allow_new_levels = FALSE, incl_autocor = TRUE, subset = NULL, nsamples = NULL, sort = FALSE, summary = TRUE, robust = FALSE, 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."response"
or "linear"
.
If "response"
results are returned on the scale
of the response variable. If "linear"
fitted values are returned on the scale of the linear predictor.FALSE
).
Only relevant if newdata
is provided.TRUE
.NULL
(the default), all samples are used.NULL
(the default) all samples are used.
Ignored if subset
is not NULL
.FALSE
; default) or in the order of the
time series (TRUE
).TRUE
.FALSE
(the default) the mean is used as
the measure of central tendency and the standard deviation as
the measure of variability. If TRUE
, the median and the
median absolute deivation (MAD) are applied instead.
Only used if summary
is TRUE
.quantile
function. Only used if summary
is TRUE
.object
.
The output depends on the family:
If summary = TRUE
it is a N x E x C array
for categorical and ordinal models and a N x E matrix else.
If summary = FALSE
it is a S x N x C array
for categorical and ordinal models and a S x N matrix else.
N is the number of observations, S is the number of samples,
C is the number of categories, and E is equal to length(probs) + 2
.
NA
values within factors in 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 models fitted with brms <= 0.5.0="" only:="" be="" careful="" when="" using="" 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.
=>
## Not run:
# ## fit a model
# fit <- brm(rating ~ treat + period + carry + (1|subject),
# data = inhaler)
#
# ## extract fitted values
# fitted_values <- fitted(fit)
# head(fitted_values)
#
# ## plot fitted means against actual response
# dat <- as.data.frame(cbind(Y = standata(fit)$Y, fitted_values))
# ggplot(dat) + geom_point(aes(x = Estimate, y = Y))
# ## End(Not run)
Run the code above in your browser using DataLab