---
title: "Constrained ADEA model"
author: 
 - Fernando Fernandez-Palacin^[Universidad de Cádiz, fernando.fernandez@uca.es]
 - Manuel Munoz-Marquez^[Universidad de Cádiz, manuel.munoz@uca.es]
date: "`r Sys.Date()`"
bibliography: dea.bib
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Constrained ADEA model}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 6,
  fig.height = 4
)
library('adea')
```

# Introduction

Variable selection in Data Envelopment Analysis (DEA) is a critical aspect that demands careful consideration before the results of an analysis are applied in a real-world scenario.
This is because the outcomes can undergo significant changes based on the variables included in the model.
As a result, variable selection stands as a pivotal step in every DEA application.

The variable selection process may lead to the removal of a variable that a decision-maker might want to retain for political, tactical, or other reasons.
However, if no action is taken, the contribution of that variable will be negligible.
The `cadea` function provides a means to ensure that the contribution of a variable to the model is at least a specified value.

For more information about loads see the help of the package \code{\link{adea}} or see [@Fernandez2018] and [@Villanueva2021].

Let's load and examine the `tokyo_libraries` dataset using the following code:
```{r}
data(tokyo_libraries)
head(tokyo_libraries)
```

# Constrained ADEA

First, let's perform an ADEA analysis with the following code:
```{r}
input <- tokyo_libraries[, 1:4]
output <- tokyo_libraries[, 5:6]
m <- adea(input, output)
summary(m)
```
This analysis reveals that `Area.I1` has a load value below 0.6, indicating that its contribution to the DEA model is negligible.

With the subsequent `cadea` call, the contribution of `Area.I1` is enforced to be greater than 0.6:
```{r}
mc <- cadea(input, output, load.min = 0.6, load.max = 4)
summary(mc)
```

It is worth noting that the maximum value of a variable's load is the maximum number of variables of its type, so setting `load.max = 4` has no effect on the results.
As a result, the load level increases to the specified value of 0.6, causing a slight decrease in the average efficiency.

To compare the two efficiency sets, it is essential to observe that the Spearman correlation coefficient between them is `r round(cor(m$eff, mc$eff, method = 'spearman'), 4)`.
This can also be visualized in the following plot:
```{r echo=FALSE}
plot(m$eff, mc$eff, main ='Initial efficiencies vs constrained model efficiencies')
```

All of these findings indicate that, in this particular case, the changes are minimal.
More substantial changes can be expected if `load.min` is increased.

# References