R code for fitting a copula to censored data

The following R code fits a bivariate (Archimedean or elliptical) copula to data where one of the variables contains censored observations. The censored observations can be left, right or interval censored.

copula-censored-data

Two-stage parametric ML method
The copula is fitted using the two-stage parametric ML approach (also referred to as the Inference Functions for Margins [IFM] method). This method fits a copula in two steps:

  1. Estimate the parameters of the marginals
  2. Fix the marginal parameters to the values estimated in first step, and subsequently estimate the copula parameters.

Continue reading R code for fitting a copula to censored data

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.

quantile-regression-multivariate-copula

Continue reading R code for fitting a multiple (nonlinear) quantile regression model by means of a 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).

nonlinear-quantile-regression-copulas

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

R code for constructing probability plots

Probability plots are a tool for assessing whether the observed data follow a particular distribution.

probability-plotExample of a probability plot for a Beta distribution

In short, if all data points in a probability plot fall on an approximate straight line, then you may assume that the data fit to the distribution. In the figure above, for instance, all points seem to fall on a straight line in a Beta probability plot. As a result, we may assume that these data points come from a Beta distribution.

The following R code constructs probability plots. Continue reading R code for constructing probability plots

R code for constructing confidence areas around the level curves of bivariate copulas

In his 2013 paper called An uncertain journey around the tails of multivariate hydrological distributions Serinaldi discusses the problem of constructing confidence areas for the level curves of bivariate copulas. A level curve at a specific p-value (also referred to as a p-level curve) may be used for estimating the p-th quantiles.

ci-level-curve-copula

The R code below implements a nonparametric bootstrap method for computing such confidence areas for p-level curves. Continue reading R code for constructing confidence areas around the level curves of bivariate copulas