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
m <- gamlss2(f, data = film90, family = BCPE)
## compute quantiles using "newdata"
nd <- film90[1:10, ]
print(quantile(m, newdata = nd))
## plot sorted quantiles
quantile(m, plot = TRUE)
## quantile plot using covariate data
quantile(m, plot = TRUE, variable = TRUE)
## plot without raw data
quantile(m, plot = TRUE, variable = TRUE, data = FALSE)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, integer, or character. Should quantiles be plotted against a covariate? If TRUE, the single model covariate is used. Alternatively, a covariate can be selected by position or name. This option is only available 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
The estimated quantiles. For multiple probabilities, a data frame is returned. For a single probability and variable = NULL, the result is simplified to a numeric vector.
See Also
gamlss2.