## R code for fitting a quantile regression model to censored data by means of a copula

In my previous blog post I showed how to fit a copula to censored data. For the ease of use, I’m going to call these fitted copulas censored copulas.

The following R code demonstrates how these censored copulas in turn can be used for fitting a quantile regression model to censored data.

A more detailed description of the method employed for fitting the quantile regression model can be found in this blog post. Continue reading R code for fitting a quantile regression model to censored data by means of a copula

## R code for fitting a multiple (nonlinear) quantile regression model by means of a copula

In my previous blog post I demonstrated how to fit a simple (nonlinear) quantile regression model using a bivariate copula. In these simple quantile regression models, we have one independent and one dependent variable.

The R code below may be used for fitting a multiple (nonlinear) quantile regression model. These multiple (nonlinear) quantile regression models have two or more independent variables (but only one dependent variable). The R code fits these multiple (nonlinear) quantile regression models by means of a multivariate (Archimedean or elliptical) copula.

## R code for performing quantile regression using bivariate copulas

Nelsen explained in his 1999 book An introduction to copulas how to fit a (nonlinear) quantile regression model by means of a bivariate copula (pp. 175-176).

In short, Nelsen’s method for fitting a (nonlinear) quantile regression model is as follows:

1. Take the partial derivative of the copula function C(u, v) with respect to u, where u and v are both defined in [0, 1]. Denote this partial derivative by cu(u, v), and note that cu(u, v) = P{V ≤ v | U = u}.
2. For fitting the quantile regression model, set cu(u, v) = p, where p is defined in [0, 1].
3. For regressing v on u, evaluate cu(u, v) at u, and subsequently solve cu(u, v) = p for v (or, similarly, solve 0 = cu(u, v) – p for v).
4. Replace u by Fx-1(u) and v by Fy-1(v), where Fx-1(·) and Fy-1(·) are the quantile functions for x (=independent variable) and y (=dependent variable), respectively.

The following R code implements this copula method proposed by Nelsen for fitting a (nonlinear) quantile regression model. In addition, the R code may also compute confidence intervals for the fitted quantiles using a Monte-Carlo method. Continue reading R code for performing quantile regression using bivariate copulas