Quantiles for GAMLSS

Description

The function computes estimated quantiles and optionally produces a plot.

Usage

## S3 method for class 'gamlss2'
quantile(x, probs = c(0.025, 0.25, 0.50, 0.75, 0.975),
  variable = NULL, newdata = NULL,
  plot = FALSE, data = TRUE,
  n = 100L, ...)

Arguments

x An object of class “gamlss2”.
probs Numeric vector of probabilities with values in [0,1].
variable Logical or integer, should quantiles be plotted using the covariate data? Note that the variable option is only possible for single covariate models.
newdata Data frame that should be used for computing the quantiles.
plot Logical, should a plot be shown?
data Logical, should the raw data be added to the plot?
n Integer, number of observations that should be used to compute an equidistant grid for the selected variable.
Arguments such as col, legend = TRUE/FALSE. See the examples.

Details

The function applies the predict method to determine the parameters of the response distribution. It then computes the quantiles as specified in the argument probs.

Value

A data frame of the estimated quantiles.

See Also

gamlss2.

Examples

library("gamlss2")


data("film90", package = "gamlss.data")

## model formula
f <-  ~ s(lboopen)
f <- rep(list(f), 4)
f[[1]] <- update(f[[1]], lborev1 ~ .)

## estimate model
b <- gamlss2(f, data = film90, family = BCPE)

## compute quantiles using "newdata"
nd <- film90[1:10, ]
print(quantile(b, newdata = nd))

## plot sorted quantiles
quantile(b, plot = TRUE)

## quantile plot using covariate data
quantile(b, plot = TRUE, variable = TRUE)

## plot without raw data
quantile(b, plot = TRUE, variable = TRUE, data = FALSE)