'DEA: How to implement weight constraints in R
I am trying to conduct a CCR Data Envelopment Analyis with R, but I am having trouble of adding weight constraints into my R-Code. I am trying to recreate the DEA model of Powers and McMullen (2000), where they restricted the weights for inputs and ouputs with 0.2 and 5, respectively Screenshot weight constraints. Meaning, that an attribute can only be 5 times as important as other attributes and vice versa. Can you help me implementing these weight restrictions into my R-Code. Thanks in advance!
inputs <-data.frame(my_data[c(2,4,7,8)])
outputs <-data.frame(my_data[c(3,5,6,9)])
N <-dim(my_data)[1]
s <-dim(inputs)[2]
m <-dim(outputs)[2]
library("lpSolve")
f.rhs <- c(rep(0,1,N),1)
f.dir <- c(rep("<=",1,N),"=")
aux <- cbind(-1*inputs,outputs)
for(i in 1:N){
f.obj <- c(0*rep(1,s),as.numeric(outputs[i,]))
f.con <- rbind(aux,c(as.numeric(inputs[i,]),rep(0,1,m)))
results <- lp("max",as.numeric(f.obj),f.con,f.dir,f.rhs,scale=0,compute.sens=TRUE)
if (i==1){
weights <- results$solution
effcrs <- results$objval
lambdas <- results$duals[seq(1,N)]
}else{
weights <- rbind(weights,results$solution)
effcrs <- rbind(effcrs,results$objval)
lambdas <- rbind(lambdas,results$duals[seq(1,N)])
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
