fitted.mcpfit: Expected Values from the Posterior Predictive Distribution

Description Usage Arguments Value Author(s) See Also Examples

View source: R/mcpfit_methods.R

Description

Expected Values from the Posterior Predictive Distribution

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## 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 mcpfit object.

newdata

A tibble or a data.frame containing predictors in the model. If NULL (default), the original data is used.

summary

Summarise at each x-value

probs

Vector of quantiles. Only in effect when summary == TRUE.

rate

Boolean. For binomial models, plot on raw data (rate = FALSE) or response divided by number of trials (rate = TRUE). If FALSE, linear interpolation on trial number is used to infer trials at a particular x.

prior

TRUE/FALSE. Plot using prior samples? Useful for mcp(..., sample = "both")

which_y

What to plot on the y-axis. One of

  • "ct": The central tendency which is often the mean after applying the link function (default).

  • "sigma": The variance

  • "ar1", "ar2", etc. depending on which order of the autoregressive effects you want to plot.

varying
  • TRUE: All varying effects (fit$pars$varying).

    • FALSE: No varying efects (c()).

    • Character vector: Only include specified varying parameters - see fit$pars$varying.

arma

Whether to include autoregressive effects.

  • TRUE: Compute autoregressive residuals. Requires the response variable in newdata.

  • FALSE: Disregard the autoregressive effects. For family = gaussian(), predict() just use sigma for residuals.

nsamples

Integer or NULL. Number of samples to return/summarise. If there are varying effects, this is the number of samples from each varying group. NULL means "all". Ignored if both are FALSE. More samples trade speed for accuracy.

samples_format

One of "tidy" or "matrix". Controls the output format when summary == FALSE. See more under "value"

scale

One of

  • "response": return on the observed scale, i.e., after applying the inverse link function.

  • "linear": return on the parameter scale (where the linear trends are modelled).

...

Currently unused

Value

Author(s)

Jonas Kristoffer Lindeløv jonas@lindeloev.dk

See Also

pp_eval predict.mcpfit residuals.mcpfit

Examples

1
2
3
4
5
6
fitted(ex_fit)
fitted(ex_fit, probs = c(0.1, 0.5, 0.9))  # With median and 80% credible interval.
fitted(ex_fit, summary = FALSE)  # Samples instead of summary.
fitted(ex_fit,
       newdata = data.frame(time = c(-5, 20, 300)),  # New data
       probs = c(0.025, 0.5, 0.975))

mcp documentation built on Aug. 3, 2020, 5:07 p.m.