# qDEA: Quantile Data Envelopment Analysis

## Overview

The **qDEA** package provides functions for quantile Data Envelopment Analysis (qDEA), extending traditional DEA methods to allow for a specified proportion of observations to lie outside the production frontier. This approach is particularly useful for robust efficiency analysis in the presence of outliers or noise.

## Installation

You can install the released version of qDEA from CRAN with:

```r
install.packages("qDEA")
```

## Key Features

- **Standard DEA and qDEA estimation**: Compute efficiency scores using various DEA models
- **Multiple orientations**: Input-oriented, output-oriented, graph (input-output), hyperbolic, and directional distance function models
- **Returns to scale**: Support for CRS, VRS, DRS, and IRS specifications
- **Bias correction**: Bootstrap-based bias correction procedures
- **Iterative qDEA**: Automatic convergence testing for qDEA solutions
- **Peer identification**: Identify efficient peers and compute projection values
- **LP solvers**: Integration with the highs solver

## Basic Usage

```r
library(qDEA)

# Load example data
data(CST11)

# Prepare input and output matrices
X <- as.matrix(CST11$EMPLOYEES)
Y <- as.matrix(CST11$SALES)

# Run basic DEA (output-oriented, CRS)
result <- qDEA(X = X, Y = Y, orient = "out", RTS = "CRS")

# View efficiency scores
result$effvals

# Run qDEA with 10% outliers allowed
result_q <- qDEA(X = X, Y = Y, qout = 0.10, orient = "out", RTS = "CRS")

# View qDEA efficiency scores
result_q$effvalsq
```

## Advanced Features

### Bootstrap Bias Correction

```r
# Run qDEA with bootstrap bias correction
result_boot <- qDEA(X = X, Y = Y, 
                    qout = 0.10, 
                    nboot = 100,
                    orient = "out", 
                    RTS = "VRS")

# Access bias-corrected estimates
result_boot$BOOT_DATA$effvalsq.bc
```

### Multiple Inputs and Outputs

```r
# Load two-input, two-output example
data(CST22)

X <- as.matrix(CST22[, c("DOCTORS", "NURSES")])
Y <- as.matrix(CST22[, c("OUT_PATIENTS", "IN_PATIENTS")])

# Run qDEA
result <- qDEA(X = X, Y = Y, qout = 0.05, orient = "in", RTS = "VRS")
```

## Methodology

The qDEA method extends traditional DEA by allowing a pre-specified proportion (α) of observations to lie outside the estimated production frontier. This makes the method more robust to outliers and measurement error while maintaining computational efficiency through linear programming.

### Key References

- Atwood, J., and S. Shaik. (2020). "Theory and Statistical Properties of Quantile Data Envelopment Analysis." *European Journal of Operational Research*, 286:649-661. [DOI: 10.1016/j.ejor.2020.03.054](https://doi.org/10.1016/j.ejor.2020.03.054)

- Atwood, J., and S. Shaik. (2018). "Quantile DEA: Estimating qDEA-alpha Efficiency Estimates with Conventional Linear Programming." In *Productivity and Inequality*. Springer Press. [DOI: 10.1007/978-3-319-68678-3_4](https://doi.org/10.1007/978-3-319-68678-3_4)

## Getting Help

For questions and issues, please contact the package maintainer at jatwood@montana.edu.

## License

GPL-2 | GPL-3
