residuals.mcpfit: Compute Residuals From Mcpfit Objects

Description Usage Arguments Author(s) See Also Examples

View source: R/mcpfit_methods.R

Description

Equivalent to fitted(fit, ...) - fit$data[, fit$data$yvar] (or fitted(fit, ...) - newdata[, fit$data$yvar]), but with fixed arguments for fitted: rate = FALSE, which_y = 'ct', samples_format = 'tidy'.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## S3 method for class 'mcpfit'
residuals(
  object,
  newdata = NULL,
  summary = TRUE,
  probs = TRUE,
  prior = FALSE,
  varying = TRUE,
  arma = TRUE,
  nsamples = NULL,
  ...
)

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.

prior

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

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.

...

Currently unused

Author(s)

Jonas Kristoffer Lindeløv jonas@lindeloev.dk

See Also

pp_eval fitted.mcpfit predict.mcpfit

Examples

1
2
3
residuals(ex_fit)
residuals(ex_fit, probs = c(0.1, 0.5, 0.9))  # With median and 80% credible interval.
residuals(ex_fit, summary = FALSE)  # Samples instead of summary.

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