I am trying to run an output oriented DEA model and am getting following errors:
1.
Warning message:
In rbind(const.mat, const.dir.num, const.rhs) :
number of columns of result is not a multiple of vector length (arg 2)
Error in rbind(weights, results$solution[1]) :
cannot coerce type 'closure' to vector of type 'list'
I am sharing my complete code below:
library(readxl)
library(lpSolve)
library (rJava)
library(WriteXLS)
library(xlsxjars)
#defining dataset
df=data.frame(read_excel(path = "Data1.xlsx", sheet= "1"))
inputs=data.frame(df[1:2])
outputs=data.frame(df[3:4])
m=2
s=ncol(df)-m
N= nrow(df)
f.con=matrix(ncol=N+1,nrow=m+s)
for (j in 1:N)
f.rhs = c(unlist(unname(df[j,(1):(m),1])),rep(0,s), 1)
f.dir = c(rep("<=",m),rep(">=",s), "=")
f.obj = c(1, rep(0,N))
for(i in 1:m){}
f.con[i,1:(N+1)]=c(0,df[,i])
for(i in 1:m){f.con[i,1:(N+1)]=c(0,df[,i])}
for(r in (m+1):(s+m)) {f.con[r,1:(N+1)]=c(as.numeric(-df[j,r]),as.numeric(df[,r]))}
#solving the model
results =lp ("max", as.numeric(f.obj), f.con, f.dir, f.rhs, scale=0, compute.sens=F)
> Warning message:
> In rbind(const.mat, const.dir.num, const.rhs) :
number of columns of result is not a multiple of vector length (arg 2)
if (j==1) {weights = results$solution[1]
lambdas = results$solution[seq(2,(N+1))]
xbench =lambdas%*% as.matrix(inputs)
ybench =lambdas%*% as.matrix(outputs)
} else{
weights = rbind(weights, results$solution[1])
lambdas = rbind(lambdas, results$solution[seq(2,(N+1))])
xbench = lambdas %*% as.matrix(inputs)
ybench = lambdas %*% as.matrix(outputs) }
> Error in rbind(weights, results$solution[1]) :
cannot coerce type 'closure' to vector of type 'list'