posterior_predict {bayesnec} | R Documentation |
Generates posterior predictions for objects fitted by bnec
Description
Generates posterior predictions for objects fitted by bnec
.
object
should be of class bayesnecfit
or
bayesmanecfit
.
Usage
## S3 method for class 'bayesnecfit'
posterior_predict(object, ...)
## S3 method for class 'bayesmanecfit'
posterior_predict(object, ...)
Arguments
object |
An object of class |
... |
Additional arguments to
|
Value
See ?brms::posterior_predict
.
Examples
## Not run:
library(bayesnec)
# Uses default `resolution` and `x_range` to generate `newdata` internally
posterior_predict(manec_example)
# Provide user-specified `newdata`
nd_ <- data.frame(x = seq(0, 3, length.out = 200))
ppreds <- posterior_predict(manec_example, ecx_val = 50, newdata = nd_,
make_newdata = FALSE)
ncol(ppreds) == 200 # cols are x, rows are iterations
# Posterior predictions for raw input data
nec4param <- pull_out(manec_example, model = "nec4param")
preds <- posterior_predict(nec4param, make_newdata = FALSE)
x <- pull_brmsfit(nec4param)$data$x
plot(sort(x), preds[1, order(x)], type = "l", col = alpha("black", 0.1),
ylim = c(-8, 5))
for (i in seq_len(nrow(preds))[-1]) {
lines(sort(x), preds[i, order(x)], type = "l", col = alpha("black", 0.1))
}
## End(Not run)
[Package bayesnec version 2.1.2.0 Index]