View source: R/mcpfit_methods.R
predict.mcpfit | R Documentation |
Samples from the Posterior Predictive Distribution
## S3 method for class 'mcpfit'
predict(
object,
newdata = NULL,
summary = TRUE,
probs = TRUE,
rate = TRUE,
prior = FALSE,
which_y = "ct",
varying = TRUE,
arma = TRUE,
nsamples = NULL,
samples_format = "tidy",
...
)
object |
An |
newdata |
A |
summary |
Summarise at each x-value |
probs |
Vector of quantiles. Only in effect when |
rate |
Boolean. For binomial models, plot on raw data ( |
prior |
TRUE/FALSE. Plot using prior samples? Useful for |
which_y |
What to plot on the y-axis. One of
|
varying |
One of:
|
arma |
Whether to include autoregressive effects.
|
nsamples |
Integer or |
samples_format |
One of "tidy" or "matrix". Controls the output format when |
... |
Currently unused |
If summary = TRUE
: A tibble
with the posterior mean for each row in newdata
,
If newdata
is NULL
, the data in fit$data
is used.
If summary = FALSE
and samples_format = "tidy"
: A tidybayes
tibble
with all the posterior
samples (Ns
) evaluated at each row in newdata
(Nn
), i.e., with Ns x Nn
rows. If there are
varying effects, the returned data is expanded with the relevant levels for each row.
The return columns are:
Predictors from newdata
.
Sample descriptors: ".chain", ".iter", ".draw" (see the tidybayes
package for more), and "data_row" (newdata
rownumber)
Sample values: one column for each parameter in the model.
The estimate. Either "predict" or "fitted", i.e., the name of the type
argument.
If summary = FALSE
and samples_format = "matrix"
: An N_draws
X nrows(newdata)
matrix with fitted/predicted
values (depending on type
). This format is used by brms
and it's useful as yrep
in
bayesplot::ppc_*
functions.
Jonas Kristoffer Lindeløv jonas@lindeloev.dk
pp_eval
fitted.mcpfit
residuals.mcpfit
predict(demo_fit) # Evaluate at each demo_fit$data
predict(demo_fit, probs = c(0.1, 0.5, 0.9)) # With median and 80% credible interval.
predict(demo_fit, summary = FALSE) # Samples instead of summary.
predict(
demo_fit,
newdata = data.frame(time = c(-5, 20, 300)), # Evaluate
probs = c(0.025, 0.5, 0.975)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.