Skip to content

Instantly share code, notes, and snippets.

@DATAUNIRIO
Created November 10, 2025 20:16
Show Gist options
  • Select an option

  • Save DATAUNIRIO/4d2cac2d5591cdb9b3e327ab3cfb3bc4 to your computer and use it in GitHub Desktop.

Select an option

Save DATAUNIRIO/4d2cac2d5591cdb9b3e327ab3cfb3bc4 to your computer and use it in GitHub Desktop.
Benchmarking do DEA para o Juarez
# Install the Benchmarking package if you haven't already
# install.packages("Benchmarking")
# Load the library
library(Benchmarking)
# Sample data: inputs (x) and outputs (y) for a set of DMUs
# Example from the package documentation
x <- matrix(c(100, 200, 300, 500, 100, 200, 600), ncol = 1)
y <- matrix(c(75, 100, 300, 400, 25, 50, 400), ncol = 1)
# Run the DEA model (e.g., input-oriented, VRS or CRS)
# The 'dea' function returns an object of class 'Farrell'
# We'll use VRS (Variable Returns to Scale) as an example
e <- Benchmarking::dea(x, y, RTS = "VRS", ORIENTATION = "in")
e$eff
# Get the peers for each DMU
# The 'peers' function returns a matrix where each row corresponds to a DMU,
# and the columns list the indices (or names, if specified) of its peers.
# Efficient DMUs are their own peers.
peers_list <- peers(e, NAMES = TRUE)
# Print the peers
print(peers_list)
# To get the contribution (lambda values) of each peer, you can use the 'get.peers.lambda' function
lambda_list <- get.peers.lambda(e)
# Print the lambda values
print(lambda_list)
@DATAUNIRIO

Copy link
Copy Markdown
Author

The peers(e) function will return the indices (or names) of the efficient DMUs that form the benchmark for each evaluated DMU. 

The get.peers.lambda(e) function provides a list where each element corresponds to a DMU, listing its peers and the associated (\lambda ) weight. The (\lambda ) values represent the intensity variables indicating the contribution of each peer to the inefficient DMU's performance target. 

This approach allows you to identify exactly which efficient units a specific inefficient DMU should emulate to become efficient. 

@DATAUNIRIO

Copy link
Copy Markdown
Author

install.packages("farrell")

https://cran.r-project.org/web/packages/farrell/vignettes/Intro.html

library(farrell)
farrell()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment