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!
weight constraints

``` r
library("Benchmarking")
#> Lade nötiges Paket: lpSolveAPI
#> Lade nötiges Paket: ucminf
#> Lade nötiges Paket: quadprog
library("readxl")
library("lpSolve")
library("datapasta")

my_data<-tibble::tribble(
                      ~stocks,        ~`P/B`,          ~EPS,        ~`P/E`,          ~ROE,          ~ROA,           ~CR,         ~Beta, ~`1yr.return`,
                       "GOOG", "0,105320007",           "1", "0,528038527", "0,125299312", "0,536933959", "0,185208835", "0,381542741",           "1",
                         "FB", "0,201288339", "0,201880418", "0,564626358", "0,153778438", "0,668167507", "0,286678829", "0,082707193", "0,017621644",
                        "DIS", "0,655989941", "0,342545484", "0,542004395",           "1",           "1", "0,642544601", "0,310267311", "0,926164585",
                      "CMCSA", "0,738662978", "0,330823395", "0,789179683", "0,622095029", "0,725227171", "0,749205186", "0,496788817",  "0,62952056",
                         "VZ", "0,693367104", "0,304448696",  "0,93936212", "0,201148966", "0,609687719", "0,779025287",           "1", "0,757735763",
                       "NFLX",           "1", "0,233139322", "0,177801712", "0,005918114", "0,248400317",  "0,70193806", "0,467740406", "0,300504736",
                          "T", "0,892382078", "0,328869714",           "1", "0,712536726", "0,801200408",  "0,81392831", "0,745286657", "0,770396294",
                       "TMUS", "0,771501511", "0,340958118", "0,038755057", "0,936810883", "0,982910621", "0,729577844", "0,867008698",  "0,91368397",
                   "Chunghwa", "0,222162216", "0,067198502", "0,516760834", "0,345485567", "0,821260561",           "1", "0,502504454", "0,610898746",
           "Deutsche Telekom", "0,788421199", "0,355488624",  "0,85315031", "0,756535153", "0,928671559", "0,679834308", "0,612769693", "0,263626634",
            "Electronic Arts", "0,464682875", "0,300052912", "0,602069099",  "0,74719918",  "0,59237111", "0,036667614", "0,594268297", "0,761613283",
                  "Paramount",  "0,90675565", "0,327526558", "0,965374233", "0,393192633",    "0,495372", "0,339166455", "0,060884268", "0,990353243"
           )


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)
#> Error in FUN(left, right): nicht-numerisches Argument für binären Operator

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)])
  }
}
#> Warning: NAs durch Umwandlung erzeugt

#> Warning: NAs durch Umwandlung erzeugt
#> Error in rbind(aux, c(as.numeric(inputs[i, ]), rep(0, 1, m))): Objekt 'aux' nicht gefunden

Created on 2022-04-04 by the reprex package (v2.0.1)

Hello.
Thanks for providing code , but you could take further steps to make it more convenient for other forum users to help you.

Share some representative data that will enable your code to run and show the problematic behaviour.

You might use tools such as the library datapasta, or the base function dput() to share a portion of data in code form, i.e. that can be copied from forum and pasted to R session.

Also its advised if you are using packages/libraries outside of base R, to declare them.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.