I cannot run a command with the "rDEA" package

Asked

Viewed 255 times

2

I am a beginner in R and do not understand much of the solutions in English. I believe, therefore, that a forum in Portuguese can help me.

I have the following database (date):

inserir a descrição da imagem aqui

I’m trying to run the remote:

## inputs and outputs for analysis
Y = data[c('V7', 'V8')]
X = data[c('V3', 'V4','V5','V6')]
W = data[('V2')]
## Naive input-oriented DEA score for the first 20 firms under variable returns-to-scale
firms=1:19
di_naive = dea(XREF=X, YREF=Y, X=X[firms,], Y=Y[firms,], model="input", RTS="variable")
di_naive$thetaOpt
## Naive DEA score in cost-minimization model for the first 20 firms under variable returns-to-scale
ci_naive = dea(XREF=X, YREF=Y, X=X[firms,], Y=Y[firms,], W=W[firms,],
model="costmin", RTS="variable")
ci_naive$XOpt
ci_naive$gammaOpt

I am getting, however, the following error message:

> library("rDEA", lib.loc="~/R/win-library/3.3")
Using the GLPK callable library version 4.47
> data <- read.delim("~/R/win-library/3.3/data.txt", header=FALSE)
>   View(data)
> ## inputs and outputs for analysis
> Y = data[c('V7', 'V8')]
> X = data[c('V3', 'V4','V5','V6')]
> W = data[('V2')]
> ## Naive input-oriented DEA score for the first 20 firms under variable returns-to-scale
> firms=1:19
> di_naive = dea(XREF=X, YREF=Y, X=X[firms,], Y=Y[firms,], model="input", RTS="variable")
Error in dea.input(XREF = XREF, YREF = YREF, X = X, Y = Y, RTS = RTS) : 
  YREF has to be numeric matrix or data.frame.
> di_naive$thetaOpt
Error: object 'di_naive' not found
> ## Naive DEA score in cost-minimization model for the first 20 firms under variable returns-to-scale
> ci_naive = dea(XREF=X, YREF=Y, X=X[firms,], Y=Y[firms,], W=W[firms,],
+                model="costmin", RTS="variable")
Error in dea.costmin(XREF = XREF, YREF = YREF, X = X, Y = Y, W = W, RTS = RTS) : 
  YREF has to be numeric matrix or data.frame.
> ci_naive$XOpt
Error: object 'ci_naive' not found
> ci_naive$gammaOpt
Error: object 'ci_naive' not found
  • The error is saying that YREF needs to be numerical (in your case it is the Y object). Then, after you create the Y variable, run this command: Y <- as.Numeric(Y), and tell me if the error continues.

1 answer

1

Your code problem is probably in data import.

The variable Y that you create needs to be a data.frame with numerical columns or a numerical matrix. In this case, as far as I can see from the image, it is like character, because of the symbol of º that appears after the number.

One way to fix this is to use the function parse_number of the apcote readr. So you would only take the numeric value of the variable and disregard º that’s holding you back.

So you can transform your data before doing so:

library(readr)
data$V7 <- parse_number(data$V7)
data$V8 <- parse_number(data$V8)

After you run it will probably work. If an error keeps coming up that some column is not numerical, look for problems like this in other columns of your base.

  • Thank you very much, boy!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.