javierbarbero / DataEnvelopmentAnalysis.jl

A Julia package for efficiency and productivity measurement using Data Envelopment Analysis (DEA)
MIT License
10 stars 2 forks source link

[Question] I have some problem using this package #22

Closed nesteiner closed 1 year ago

nesteiner commented 1 year ago

sorry to bother you, I am not pro, and I am not familiar with Data Envelopment Analysis, so I can't understand some options of dea function, such like

dea(X, Y, orient = :Input, rts = :CRS)
  1. orient
  2. rts

actually I don't know about :Input and output


and now I need to solve the Bank Efficiency Evaluation and Bankruptcy Cause Analysis , using the CCR model , here is my code

data2017 = DataFrame(XLSX.readtable("data/A.xlsx", 1))
function handleInvalidData!(dataframe::DataFrame)
  ns = names(dataframe)
  for name in ns
    data = filter(!isequal("?"), dataframe[!, name])
    average = reduce(+, data) / length(data)
    indexs = findall(isequal("?"), dataframe[!, name])
    if !isnothing(indexs)
      dataframe[!, name][indexs] .= average
    end
  end
end

handleInvalidData!(data2017)

# important
let inputnames = ["X3", "X6", "X9", "X20", "X21", "X33", "X34", "X36", "X38", 
                  "X39", "X42", "X44", "X46", "X47", "X50", "X51", "X52", "X54",
                  "X58", "X59", "X60", "X61", "X62", "X63", "X64"]
    outputnames = ["X1", "X2", "X4", "X8", "X10", "X17", "X30", "X53", "X55",
                   "X7", "X12", "X18", "X19", "X22", "X23", "X24", "X29", "X31",
                   "X35", "X45", "X48", "X49"]

    inputs = convert(Matrix{Float64}, Matrix(select(data2017, inputnames)))[1:1000, :]
    outputs = convert(Matrix{Float64}, Matrix(select(data2017, outputnames)))[1:1000, :]

    # optimizer = DEAOptimizer(Ipopt.Optimizer, time_limit = 100000)
    dea(inputs, outputs, orient = :Input, rts = :CRS);

end

I got such warning and error image image

but when I use this code, everything is ok


let inputnames = ["X3", "X6", "X9", "X20", "X21", "X33", "X34", "X36", "X38", 
                  "X39", "X42", "X44", "X46", "X47", "X50", "X51", "X52", "X54",
                  "X58", "X59", "X60", "X61", "X62", "X63", "X64"]
    outputnames = ["X1", "X2", "X4", "X8", "X10", "X17", "X30", "X53", "X55",
                   "X7", "X12", "X18", "X19", "X22", "X23", "X24", "X29", "X31",
                   "X35", "X45", "X48", "X49"]

    inputs = convert(Matrix{Float64}, Matrix(select(data2017, inputnames)))[1:100, :]
    outputs = convert(Matrix{Float64}, Matrix(select(data2017, outputnames)))[1:100, :]

    # optimizer = DEAOptimizer(Ipopt.Optimizer, time_limit = 100000)
    dea(inputs, outputs, orient = :Input, rts = :CRS);

end

just decrease the size of matrix, I don't know why the warning and error occur, do you have any idea ?

javierbarbero commented 1 year ago

Hi. It is hard to say without having access to the data. If you share the data with me, I can replicate the error and debug what is happening. (Send me an email if you can't share it publicly.) Please check that your data does not have 0s or negative values, as this causes infeasibility. Also, infeasibilities tend to appear when there are large differences in the scale of the variables (e.g., one is measured between 0 and 1, and another in thousands or millions).

nesteiner commented 1 year ago

oh my god, I have been waiting for a long time, please give me your email so that I can send the data

javierbarbero commented 1 year ago

My contact details are here: https://www.javierbarbero.net/contact/

nesteiner commented 1 year ago

I have send it, the title is data from nesteiner

javierbarbero commented 1 year ago

Closed as the issue is related to a user data problem (negative values in inputs and outputs) and not package functionality.