# Data Envelopment Analysis (DEA) in MATLAB

URL: https://yarpiz.com/data-envelopment-analysis-ypap114
Author: Mostapha Kalami Heris
Published: 2015-09-22
Updated: 2026-10-30
Topics: Applications

> Compare DEA implementations in MATLAB with CCR, input- and output-oriented BCC, and the package-specific ratio reported by its Additive routine.

This package is an open-source MATLAB implementation of Data Envelopment Analysis (DEA). DEA measures the relative efficiency of decision making units (DMUs) from their inputs and outputs. Each efficiency value is found by solving a linear program with `linprog`.

A DMU can be a bank branch, a hospital, a school or any unit that turns inputs (staff, budget, equipment) into outputs (services, products, graduates). DEA needs no price for the inputs and outputs, and no formula for how outputs depend on inputs. It compares each unit with the best practice found in the data. The radial efficiency scores described here use 1 for the frontier and smaller values for inefficient units, subject to the model and normalization. The Additive routine reports a separate ratio described below.

DEA was introduced by Charnes, Cooper and Rhodes in 1978 ([paper](https://doi.org/10.1016/0377-2217%2878%2990138-8)). Their model is now called the CCR model.

## Models

- CCR
- Input-oriented BCC
- Output-oriented BCC
- Additive

## The CCR model

Suppose there are $K$ DMUs, each with $m$ inputs and $n$ outputs. Let $x_{jk}$ be input $j$ of DMU $k$ and $y_{ik}$ be output $i$ of DMU $k$. The efficiency of DMU $k$ is the ratio of its weighted outputs to its weighted inputs. DEA chooses the weights that are most favorable to DMU $k$, with the condition that no DMU gets a ratio above 1 with the same weights.

This ratio problem can be written as a linear program. With output weights $u_i$ and input weights $v_j$, the CCR model for DMU $k$ is:

$$
\begin{aligned}
\max_{u, v} \quad & \sum_{i=1}^{n} u_i \, y_{ik} \\
\text{subject to} \quad & \sum_{j=1}^{m} v_j \, x_{jk} = 1 \\
& \sum_{i=1}^{n} u_i \, y_{il} - \sum_{j=1}^{m} v_j \, x_{jl} \le 0, \qquad l = 1, \dots, K \\
& u_i \ge 0, \quad v_j \ge 0
\end{aligned}
$$

The optimal value is the efficiency of DMU $k$. This is exactly the linear program in `GetSingleCCREfficiency.m`. One linear program is solved for each DMU.

The CCR model assumes constant returns to scale: if a unit doubles all its inputs, it is expected to double all its outputs.

## The other models

- **Input-oriented BCC.** Banker, Charnes and Cooper (1984, [paper](https://doi.org/10.1287/mnsc.30.9.1078)) dropped the constant returns to scale assumption and allowed variable returns to scale. In the linear program above, this adds one free variable $u_0$ (positive or negative) to the objective and to every constraint. The input-oriented version asks how much the inputs could shrink while the outputs stay the same.
- **Output-oriented BCC.** The same frontier, but seen from the output side: how much the outputs could grow with the same inputs. Here the weighted output of DMU $k$ is fixed to 1, the weighted input plus a free variable $v_0$ is minimized, and the code reports the inverse of the optimal value as the efficiency.
- **Additive.** The additive model (Charnes, Cooper, Golany, Seiford and Stutz, 1985) uses the input and output slacks directly, with no input or output orientation. The code solves its multiplier form: it minimizes $\sum_j v_j x_{jk} - \sum_i u_i y_{ik} + v_0$, with all weights at least 1. It then reports the ratio $\sum_i u_i y_{ik} / (\sum_j v_j x_{jk} + v_0)$ as the efficiency.

Under the same input orientation and data assumptions, the BCC score is at least as high as the CCR score. Comparing those consistently defined radial scores helps separate technical efficiency from scale effects. The package-specific Additive ratio should not be treated as the standard sum-of-slacks measure.

## What is in the download

- `GetCCREfficiency.m`, `GetIOBCCEfficiency.m`, `GetOOBCCEfficiency.m` and `GetAdditiveEfficiency.m` compute the efficiency of all DMUs for each model.
- `GetSingleCCREfficiency.m`, `GetSingleIOBCCEfficiency.m`, `GetSingleOOBCCEfficiency.m` and `GetSingleAdditiveEfficiency.m` compute the efficiency of one DMU for each model.
- `main.m` is an example. It defines input and output data for 12 DMUs, computes the efficiency with all four models and shows the results in a bar chart.

The single DMU functions also return the optimal weights (`u` and `v`, and `u0` or `v0` where the model has them) in a second output. The efficiencies are rounded to four decimals.

## How to run

Open `main.m` in MATLAB and run it. To analyze your own data, replace the input matrix `x` and the output matrix `y`. In both matrices, each column is one DMU.

In the example, `x` has two inputs and `y` has two outputs, for 12 DMUs. Each row of a matrix is one input or one output. The bar chart shows the four efficiency values of each DMU side by side.

The code calls `linprog` and `optimoptions`, which come from MATLAB's Optimization Toolbox, so it probably needs that toolbox.

## Check the result

Check input and output units, missing values, and the direction of each measure before comparing DMUs. Inspect the linear-program solver status as well as the returned score. DEA measures performance relative to the supplied comparison set, not an absolute standard or a causal explanation. The routine labeled Additive converts its solution into a ratio, which differs from the conventional additive slack score. Report that distinction explicitly rather than comparing all four outputs as interchangeable measures.

## Applications

DEA is widely used to compare the performance of similar units, for example:

- bank branches,
- hospitals and other health care units,
- schools and universities,
- power plants and other utilities.

The results show which units are efficient. The optimal weights also show which inputs and outputs make each unit look best. Full DEA studies often add the envelopment form of the models, which names the efficient peers of each inefficient unit. This package reports the efficiencies and the weights.

## Related posts

- [Linear Programming in MATLAB: Video Tutorial](https://yarpiz.com/linear-programmin-in-matlab-linprog-yptlp190516)

## How to cite

Mostapha Kalami Heris, Data Envelopment Analysis (DEA) in MATLAB (YPAP114), Yarpiz, 2015. https://yarpiz.com/data-envelopment-analysis-ypap114
