1

I have a dataframe with identifier (IDENT), year (time), with their categories (OTEXE) and their department (CDEPT). I want to compute the efficiency score for each observation by year, categories and department. As, efficiency score are benchmarking techniques, it is better to compute it that way and then compare observations with the one more similar.

I've tried this so far:

my_dea <- function(x) Benchmarking::dea(X=as.matrix(x[,c("A", "B", "C", "D")]),
                                        Y=s.matrix(x[["E"]], RTS ="VRS", 
                                                   ORIENTATION ="out"))

score <- test[, .(eff = my_dea(.SD)), list(IDENT, time, OTEXE, CDEPT)]

c("A", "B", "C", "D") are input and "E" is the output. They should be in matrix form.

When i Run this code, I have this :

"ERROR in `[data.frame`test,  ,.(eff = my_dea(.SD)), list(IDENT, time,   : 
object 'IDENT' not found. 
jay.sf
  • 60,139
  • 8
  • 53
  • 110
  • You probably receive no answers to your question because it's not reproducible, you might want to study our [how-to-make-a-great-r-reproducible-example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) guide. – jay.sf Mar 08 '21 at 16:54
  • Oh I see. But i found the solutions anyway. I will pay attention to how to make a great reproducible example the next time. Thanks so much for the time! – Thierno Bocar Diop Mar 09 '21 at 17:13
  • Very welcome. In this case you may make an own answer. It would perhaps help someone who comes across your question, which already has 26 views;) – jay.sf Mar 09 '21 at 17:22

1 Answers1

1

Yeah sure! I've constructed a function:

my_dea <- function(X, Y) {
X <- as.matrix(df[, c("A", "B", "C", "D"])
Y <- as.matrix(df[,"E"])
benchmarking::dea.boot(X, Y, NREP = 2000, RTS="vrs", ORIENTATION ="out")
}
 eff <- df1 %>% group_by(IDENT, TIME, CDEPT, OTEXE) %>% my_dea

Thanks @jay.sf !