bnec
R/posterior_predict.R
posterior_predict.Rd
Generates posterior predictions for objects fitted by bnec
.
object
should be of class bayesnecfit
or
bayesmanecfit
.
# S3 method for class 'bayesnecfit'
posterior_predict(object, ...)
# S3 method for class 'bayesmanecfit'
posterior_predict(object, ...)
An object of class bayesnecfit
or
bayesmanecfit
.
Additional arguments to
posterior_predict
.
if (FALSE) { # \dontrun{
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))
}
} # }