| fitted.mcpfit {mcp} | R Documentation |
Expected Values from the Posterior Predictive Distribution
Description
Expected Values from the Posterior Predictive Distribution
Usage
## S3 method for class 'mcpfit'
fitted(
object,
newdata = NULL,
summary = TRUE,
probs = TRUE,
rate = TRUE,
prior = FALSE,
which_y = "ct",
varying = TRUE,
arma = TRUE,
nsamples = NULL,
samples_format = "tidy",
scale = "response",
...
)
Arguments
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 |
scale |
One of
|
... |
Currently unused |
Value
If
summary = TRUE: Atibblewith the posterior mean for each row innewdata, IfnewdataisNULL, the data infit$datais used.If
summary = FALSEandsamples_format = "tidy": Atidybayestibblewith all the posterior samples (Ns) evaluated at each row innewdata(Nn), i.e., withNs x Nnrows. 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
tidybayespackage for more), and "data_row" (newdatarownumber)Sample values: one column for each parameter in the model.
The estimate. Either "predict" or "fitted", i.e., the name of the
typeargument.
If
summary = FALSEandsamples_format = "matrix": AnN_drawsXnrows(newdata)matrix with fitted/predicted values (depending ontype). This format is used bybrmsand it's useful asyrepinbayesplot::ppc_*functions.
Author(s)
Jonas Kristoffer Lindeløv jonas@lindeloev.dk
See Also
pp_eval predict.mcpfit residuals.mcpfit
Examples
fitted(demo_fit)
fitted(demo_fit, probs = c(0.1, 0.5, 0.9)) # With median and 80% credible interval.
fitted(demo_fit, summary = FALSE) # Samples instead of summary.
fitted(demo_fit,
newdata = data.frame(time = c(-5, 20, 300)), # New data
probs = c(0.025, 0.5, 0.975))