Executive Summary: Efficiency Using DEA (Data Envelopment Analysis) Method


# Verificación e instalación de paquetes
if(!require(tidyverse)) install.packages("tidyverse")
if(!require(ggrepel)) install.packages("ggrepel")
if(!require(readxl)) install.packages("readxl")

# Carga en memoria
library(tidyverse)
library(ggrepel)
library(readxl)
# Lectura de la base de datos
datos <- read_excel("datos_dmu_3.xlsx")

# Transformación de los datos
df_long <- datos %>%
  mutate(
    Gasto_kUSD_año = Valor_Comprado / 1000,
    Lineas_xOC = Lineas_xOC,
    Compradores = Compradores,
    Output_Plazo = Plazo_Pago_Proveedores,
    Cohorte = as.factor(Cohorte)
  ) %>%
  pivot_longer(
    cols = c(Gasto_kUSD_año, Lineas_xOC, Compradores),
    names_to = "Tipo_Input",
    values_to = "Valor_Input"
  )

3. Cálculo de Fronteras de Eficiencia

Se calcula la envolvente convexa para delimitar la frontera de eficiencia en cada una de las variables de entrada analizadas.

df_fronteras_facet <- df_long %>%
  group_by(Tipo_Input) %>%
  do({
    d <- .
    # Se calcula el índice de los puntos que conforman la envolvente convexa
    indices <- chull(d$Valor_Input, d$Output_Plazo)
    d[indices, ]
  }) %>%
  arrange(Tipo_Input, Valor_Input)

4. Visualización de Meta-Fronteras

Se genera el gráfico final. Se implementa un etiquetado exhaustivo para asegurar la identificación unívoca de cada DMU en el reporte.

ggplot(df_long, aes(x = Valor_Input, y = Output_Plazo)) +
  # Polígono de frontera
  geom_polygon(data = df_fronteras_facet, fill = "#8e44ad", alpha = 0.1) +
  geom_path(data = df_fronteras_facet, color = "black", linewidth = 0.8) +
  
  # Puntos de dispersión
  geom_point(aes(color = Cohorte), alpha = 0.6, size = 1.5) +
  
  # Etiquetado  para mostrar todas las DMUs
  geom_text_repel(
    aes(label = DMU),
    size = 2.2,                  
    max.overlaps = Inf,          
    force = 2,                   
    point.padding = 0.2,         
    box.padding = 0.3,           
    min.segment.length = 0,      
    segment.color = "grey50",
    segment.linewidth = 0.2
  ) +
  
  # Facetado y estética
  facet_wrap(~ Tipo_Input, scales = "free_x") +
  scale_color_brewer(palette = "Dark2") +
  labs(
    title = "Identificación Completa de DMUs en Meta-Fronteras",
    subtitle = "Output: Plazo de Pago a Proveedores | Análisis de Capacidad de Negociación",
    x = "Valor del Recurso (Input)",
    y = "Plazo de Pago (Días)"
  ) +
  theme_minimal() +
  theme(
    legend.position = "bottom", 
    strip.text = element_text(face = "bold")
  )

#The following link displays the trajectory of DMUs between 2000 and 2025 relative to Argentina’s GDP per capita and inflation rates. This visualization illustrates the evolution of the metafrontier (represented by the mesh) and the positioning of individual DMUs (indicated by the dots). 

#Copy and paste in google brower the next link

# https://gemini.google.com/share/b1e7bed85052

```