quantile.gam: Conditional quantiles a GAM object

Description Usage Arguments Value Examples

View source: R/quantile_gam.R

Description

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

Usage

1
2
## 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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/gamUtils documentation built on Jan. 10, 2021, 4:49 p.m.