quantile.gam: Conditional quantiles a GAM object

View source: R/quantile_gam.R

quantile.gamR Documentation

Conditional quantiles a GAM object

Description

This method can be used to get the estimated conditional quantiles of the response variable.

Usage

## S3 method for class 'gam'
quantile(x, probs, newdata, w = NULL, offset = NULL, ...)

Arguments

x

the output of a gam() or bam() call.

probs

numeric vector of probabilities with values in (0,1).

newdata

Optional new data frame or list to be passed to predict.gam.

...

funther arguments to be passed to predict.

Value

A matrix where each column is a vector of estimated quantiles responses. The number of rows is equal to the number of responses in the fitted object or in newdata.

Examples

library(mgcvUtils); library(MASS)
b <- gam(list(accel~s(times,k=20,bs="ad"),~s(times)),
         data=mcycle,family=gaulss())

qfit <- quantile(b, c(0.05, 0.25, 0.5, 0.75, 0.95))

plot(mcycle, ylim = c(-160, 100))
for(ii in 1:ncol(qfit)){
  lines(mcycle$times, qfit[ , ii], col = 2)
}

dill/mgcvUtils documentation built on Oct. 14, 2024, 7:30 p.m.