# getQuantile: Getting the partial quantile function for a term In gamlss: Generalised Additive Models for Location Scale and Shape

## Description

This function can be used to calculate the partial effect that an explanatory variable has on a specific quantile.

By ‘partial effect’ function we mean how the term influence the quantile given that the rest of explanatory terms are constant.

The function takes a GAMLSS object and for the range of a specified explanatory (by fixing the rest of the terms at specified values), calculates the effect that this term has on the a quantile of the distribution. That is, it shows the effect that the particular term has on the quantile. The ‘partial’ quantile is calculated on a finite grid of values and then the function is approximated (using the `splinefun()`) and saved.

The saved function can be used to calculate the first derivative. This first derivatives shows the chance of the quantile function for a small change in the explanatory variable, by fixing the rest of the explanatory variables at a constant values.

## Usage

 ```1 2 3``` ```getQuantile(obj = NULL, term = NULL, quantile = 0.9, data = NULL, n.points = 100, how = c("median", "last"), fixed.at = list(), plot = FALSE) ```

## Arguments

 `obj` A `gamlss` object `term` an explanatory variable (at the moment works with with continuous) `quantile` the required quantile of the distribution `data` the data.frame (not needed if is declared on `obj`) `n.points` the number of points in which the quantile function needs evaluation `how` whether for extra continuous explanatory variables should fixed at the median or the last observation in the data `fixed.at` a list indicating at which values the rest of the explanatory terms should be fixed `plot` whether to the plot the partial quantile function and its first derivatives

## Details

The function `getQuantile()` relies on the `predictAll()` function to evaluate the distribution parameters at a grid (default 100 points) of the specified term (given that the the rest of the terms are fixed). Then the inverse cdf is used to calculate the partial quantile. The function then is approximated using `splinefun()`) and saved.

## Value

A function is created which can be used to evaluate the partial effect of the explanatory variable on a specified quantile.

## Author(s)

Mikis Stasinopoulos

## References

Rigby, R. A. and Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion), Appl. Statist., 54, part 3, pp 507-554.

Rigby, R. A., Stasinopoulos, D. M., Heller, G. Z., and De Bastiani, F. (2019) Distributions for modeling location, scale, and shape: Using GAMLSS in R, Chapman and Hall/CRC. An older version can be found in https://www.gamlss.com/.

Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R. Journal of Statistical Software, Vol. 23, Issue 7, Dec 2007, https://www.jstatsoft.org/v23/i07/.

Stasinopoulos D. M., Rigby R.A., Heller G., Voudouris V., and De Bastiani F., (2017) Flexible Regression and Smoothing: Using GAMLSS in R, Chapman and Hall/CRC.

`gamlss`, `getPEF`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35``` ```library(gamlss) data(rent) m1 <- gamlss(R~pb(Fl)+pb(A)+B+loc, data=rent, family=GA) FF<-getQuantile(m1, quantile=0.9, term="A", plot=TRUE) FF(1960) FF(1060, deriv=1) FF(1060, deriv=2) ## Not run: # plotting partial quantile # .05, 0.25, 0.5, 0.75, 0.95 # at the default values # Fl = median(Fl), B=0, and loc=2 plot(R~A, data=rent, col="lightgray", pch=20) for (i in c(.05, 0.25, 0.5, 0.75, 0.95)) { Qua <- getQuantile(m1, quantile=i,term="A") curve(Qua, 1900, 1985, lwd=1, lty=1, add=T) } # plotting at values Fl=60, B=1, and loc=1. for (i in c(.05, 0.25, 0.5, 0.75, 0.95)) { Qua <- getQuantile(m1, quantile=i,term="A", fixed.at=list(Fl=60, B=1, loc=1)) curve(Qua, 1900, 1985, lwd=1, lty=2, col="red", add=T) } # plotting at Fl=60, B=1 and loc=1. for (i in c(.05, 0.25, 0.5, 0.75, 0.95)) { Qua <- getQuantile(m1, quantile=i,term="A", fixed.at=list(Fl=120, B=0, loc=3)) curve(Qua, 1900, 1985, lwd=1, lty=3, col="blue", add=T) } ## End(Not run) ```

### Example output  ```Loading required package: splines

Attaching package: 'gamlss.data'

The following object is masked from 'package:datasets':

sleep

**********   GAMLSS Version 5.1-3  **********
For more on GAMLSS look at http://www.gamlss.org/
Type gamlssNews() to see new features/changes/bug fixes.

GAMLSS-RS iteration 1: Global Deviance = 27794.29
GAMLSS-RS iteration 2: Global Deviance = 27794.35
GAMLSS-RS iteration 3: Global Deviance = 27794.35
GAMLSS-RS iteration 4: Global Deviance = 27794.35
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
 1124.951
 2438.436
 -5.880155
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
new prediction
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
New way of prediction in pb()  (starting from GAMLSS version 5.0-3)
```

gamlss documentation built on March 31, 2021, 5:10 p.m.