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 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

R code for constructing bootstrap confidence intervals for the hazard function

The following R code may be used for computing the hazard function (also known as the hazard rate) of the Accelerated Failure Time model. The code computes the hazard function for failure times that follow either a Weibull or lognormal distribution.

The code also computes normal-approximation and bootstrap confidence intervals for the hazard function. For calculating the latter confidence intervals the code employs the nonparametric bootstrap-t method.

AFT model hazard function bootstrap ci

Continue reading R code for constructing bootstrap confidence intervals for the hazard function

R code for constructing bootstrap confidence intervals for stress-strength models

The following R code may be used for constructing bias-corrected percentile confidence intervals for stress-strength models. These bias-corrected percentile confidence intervals are obtained with a bootstrapping method.

The code focuses at first on a situation in which stress and strength both follow a normal distribution. However, any other combination of distributions may be used in the R code (e.g, having stress follow a lognormal distribution, while strength a Weibull distribution). In fact, it will be demonstrated how to change the code such that the stress and strength both follow a Weibull distribution.

A comprehensive account of bootstrap confidence intervals for stress-strength models is given in Barbiero, A. (2011), Confidence Intervals for Reliability of Stress-Strength Models in the Normal Case, Communications in Statistics – Simulation and Computation, 40, 907-925. Note though that the bootstrap confidence intervals described/reported by Alessandro Barbiero in his 2011 paper are standard (or simple) percentile confidence intervals and not bias-corrected percentile confidence intervals.
Alessandro Barbiero also maintains an R package called StressStrength. However, the package is limited to situations in which stress and strength are both normally distributed.

Continue reading R code for constructing bootstrap confidence intervals for stress-strength models

Error propagation in R: addition in quadrature versus the bootstrap method

Physicists and engineers often have to calculate the uncertainty in a derived quantity.

For instance, a test engineer measures two angles. The uncertainty (or error) in these measurements appears to be +/- 1 degree. Subsequently, the engineer calculates the sum of these two angles. This sum is a derived quantity. But note that this derived quantity is composed of two measurements each having their own uncertainties, so what is the uncertainty (or error) in this derived quantity? In other words, how propagates the uncertainty from the measured quantities (the two angles) to a derived quantity (sum of two angles). For calculating the uncertainty in this derived quantity, physicists and engineers rely on what is called the addition in quadrature procedure.

The addition in quadrature procedure provides an estimate of the Standard Deviation Of the Mean (SDOM), which is a quantification of the uncertainty in a derived quantity. This SDOM, in turn, can be used for constructing confidence intervals for the derived quantity.
Bootstrap methods (such as the bias-corrected bootstrap method) provide another way of obtaining confidence intervals for the derived quantity.

The following R code shows how to compute confidence intervals for a derived physical quantity with (1) the addition in quadrature procedure, and (2) the bias-corrected bootstrap method. The code demonstrates that these two methods usually yield very similar confidence intervals.

Continue reading Error propagation in R: addition in quadrature versus the bootstrap method