Tải gói và data

RTS:

0 fdh: Free disposability hull, no convexity assumption

1 vrs: Variable returns to scale, convexity and free disposability

2 drs: Decreasing returns to scale, convexity, down-scaling and free disposability

3 crs: Constant returns to scale, convexity and free disposability

4 irs: Increasing returns to scale, (up-scaling, but not down-scaling), convexity and free disposability

5 irs2: Increasing returns to scale (up-scaling, but not down-scaling), additivity, and free disposability

6 add: Additivity (scaling up and down, but only with integers), and free disposability

7 fdh+: A combination of free disposability and restricted or local constant return to scale

(Gói deaR chưa hỗ trợ rstudio)

https://rbensua.shinyapps.io/deaR/ deaR trên shinyapp

suppressPackageStartupMessages(library(deaR))
suppressPackageStartupMessages(library(Benchmarking))
data("PFT1981")
head(PFT1981)
##    Site Education Occupation Parental Counseling Teachers Reading  Math
## 1 Site1     86.13      16.24    48.21      49.69        9   54.53 58.98
## 2 Site2     29.26      10.24    41.96      40.65        5   24.69 33.89
## 3 Site3     43.12      11.31    38.19      35.03        9   36.41 40.62
## 4 Site4     24.96       6.14    24.81      25.15        7   14.94 17.58
## 5 Site5     11.62       2.21     6.85       6.37        4    7.81  6.94
## 6 Site6     11.88       4.97    18.73      18.04        4   12.59 16.85
##   Coopersmith Program
## 1       38.16     PFT
## 2       26.02     PFT
## 3       28.51     PFT
## 4       16.19     PFT
## 5        5.37     PFT
## 6       12.84     PFT
x<- as.matrix(PFT1981[,2:6])
y<- as.matrix(PFT1981[,c(7,8,9)])

1. Mô hình DEA, Stata:dea

Vẽ đường bao

dea.plot(x,y,RTS="vrs",ORIENTATION="in-out",txt=LETTERS[1:length(x)], )
dea.plot(x,y,RTS="crs",ORIENTATION="in-out",add=TRUE,lty="dashed", col="red", lwd=2)

Ước lượng hiệu quả

## Cách 1
dulieu <- PFT1981
dlieu <- read_data(dulieu, inputs = 2:6,outputs = 7:9 , dmus=1)
deacrs <- model_basic(dlieu,orientation = "io",rts = "crs")
efficiencies(deacrs)
## NULL
#slacks(deacrs)
#lambdas(deacrs)
#targets(deacrs)
#references(deacrs)
#rts(deacrs)

deavrs <- model_basic(dlieu,orientation = "io",rts = "vrs")
efficiencies(deavrs)
## NULL
#slacks(deavrs)
#lambdas(deavrs)
#targets(deavrs)
#references(deavrs)
#rts(deavrs)

## Cách 2
dea(x, y, RTS="crs", ORIENTATION="in")
##      1      2      3      4      5      6      7      8      9     10     11 
## 0.9192 0.9008 0.9268 0.8933 0.9293 0.9027 0.8883 0.8999 0.8444 0.9287 0.9759 
##     12     13     14     15     16     17     18     19     20     21     22 
## 0.9726 0.8578 0.9294 1.0000 0.9393 1.0000 1.0000 0.9453 1.0000 1.0000 1.0000 
##     23     24     25     26     27     28     29     30     31     32     33 
## 0.9583 1.0000 0.9603 0.9307 1.0000 0.9443 0.8290 0.8905 0.8321 0.8952 0.9271 
##     34     35     36     37     38     39     40     41     42     43     44 
## 0.8458 1.0000 0.7883 0.8379 0.8971 0.9352 0.9496 0.9414 0.9474 0.8642 1.0000 
##     45     46     47     48     49     50     51     52     53     54     55 
## 0.8802 0.8964 1.0000 1.0000 1.0000 0.9569 0.9198 1.0000 0.8619 1.0000 0.9903 
##     56     57     58     59     60     61     62     63     64     65     66 
## 1.0000 0.9257 1.0000 0.9151 0.9753 0.8815 1.0000 0.9610 0.9167 0.9646 0.9258 
##     67     68     69     70 
## 0.9270 0.9912 1.0000 0.9474
dea(x, y, RTS="vrs", ORIENTATION="in")
##      1      2      3      4      5      6      7      8      9     10     11 
## 0.9618 0.9010 0.9348 0.9016 1.0000 0.9099 0.8914 0.9050 0.8584 0.9408 1.0000 
##     12     13     14     15     16     17     18     19     20     21     22 
## 1.0000 0.8623 0.9856 1.0000 0.9501 1.0000 1.0000 0.9526 1.0000 1.0000 1.0000 
##     23     24     25     26     27     28     29     30     31     32     33 
## 0.9748 1.0000 0.9787 0.9425 1.0000 0.9903 0.8833 0.8933 0.8369 1.0000 0.9521 
##     34     35     36     37     38     39     40     41     42     43     44 
## 0.8590 1.0000 0.7929 0.8392 1.0000 0.9415 0.9497 0.9523 0.9531 0.8647 1.0000 
##     45     46     47     48     49     50     51     52     53     54     55 
## 1.0000 0.9129 1.0000 1.0000 1.0000 0.9582 0.9199 1.0000 0.8696 1.0000 0.9993 
##     56     57     58     59     60     61     62     63     64     65     66 
## 1.0000 0.9269 1.0000 1.0000 0.9804 0.8927 1.0000 0.9633 0.9302 0.9754 0.9356 
##     67     68     69     70 
## 0.9460 1.0000 1.0000 0.9640

2.Mô hình profit

Cách 1

# Example 1. Replication of results in Coelli et al. (1998, p.166).
# Cost efficiency model.
data("Coelli_1998")
head(Coelli_1998)
##   dmus input1 input2 output price_input1 price_input2 price_output
## 1 DMU1      2      5      1            1            3            2
## 2 DMU2      2      4      2            1            3            3
## 3 DMU3      6      6      3            1            3            2
## 4 DMU4      3      2      1            1            3            3
## 5 DMU5      6      2      2            1            3            3
# Selection of prices: input_prices is the transpose where the prices for inputs are.
input_prices <- t(Coelli_1998[, 5:6])
data_example1 <- read_data(Coelli_1998, ni = 2, no = 1)
result1 <- model_profit(data_example1,
price_input = input_prices, rts = "crs", restricted_optimal = FALSE)
# notice that the option by default is restricted_optimal = TRUE
efficiencies(result1)
## NULL
# Example 2. Revenue efficiency model.
data("Coelli_1998")
# Selection of prices for output: output_prices is the transpose where the prices for outputs are.
output_prices <- t(Coelli_1998[, 7])
data_example2 <- read_data(Coelli_1998, ni = 2, no = 1)
result2 <- model_profit(data_example2, price_output = output_prices, rts = "crs", restricted_optimal = FALSE)
# notice that the option by default is restricted_optimal = TRUE
efficiencies(result2)
## NULL
# Example 3. Profit efficiency model.
data("Coelli_1998")
# Selection of prices for inputs and outputs: input_prices and output_prices are
# the transpose where the prices (for inputs and outputs) are.
input_prices <- t(Coelli_1998[, 5:6])
output_prices <- t(Coelli_1998[, 7])
data_example3 <- read_data(Coelli_1998, ni = 2, no = 1)
result3 <- model_profit(data_example3, price_input = input_prices, price_output = output_prices, rts = "crs", restricted_optimal = FALSE)
# notice that the option by default is restricted_optimal = TRUE
efficiencies(result3)
## NULL

Cách 2

# Cho 2 giai đoạn
x0 <- matrix(c(10, 28, 30, 60),ncol=1)
y0 <- matrix(c(5, 7, 10, 15),ncol=1)
x1 <- matrix(c(12, 26, 16, 60 ),ncol=1)
y1 <- matrix(c(6, 8, 9, 15 ),ncol=1)
dea.plot(x0, y0, RTS="vrs", txt=TRUE)
dea.plot(x1, y1, RTS="vrs", add=TRUE, col="red")
points(x1, y1, col="red", pch=16)
text(x1, y1, 1:dim(x1)[1], col="red", adj=-1)

m <- malmq(x0,y0,,x1,y1,,RTS="vrs")
print("Malmquist index for change in productivity, technology change:")
## [1] "Malmquist index for change in productivity, technology change:"
print(m$mq)
## [1] 0.9860133 1.2486943 1.4454362 1.0000000
print("Index for change of frontier:")
## [1] "Index for change of frontier:"
print(m$tc)
## [1] 0.9860133 1.4230249 1.4454362 1.0000000

3. Mô hình malmquis (TFPC), stata:malmq2

# Replication of results in Wang and Lan (2011, p. 2768)
data("Economy")
data_example <- read_malmquist(datadea = Economy,nper = 5,arrangement = "horizontal",ni = 2,no = 1)
result <- malmquist_index(data_example, orientation = "io")
mi <- result$mi
effch <- result$ec
tech <- result$tc

# Example 2. With dataset in long format.
# Replication of results in Wang and Lan (2011, p. 2768)
data("EconomyLong")
data_example2 <- read_malmquist(EconomyLong,percol = 2,arrangement = "vertical",inputs = 3:4,outputs = 5)

result2 <- malmquist_index(data_example2, orientation = "io")
mi2 <- result2$mi
effch2 <- result2$ec
tech2 <- result2$tc

# Example 3. Replication of results in Grifell-Tatje and Lovell (1999, p. 100).
data("Grifell_Lovell_1999")
data_example <- read_malmquist(Grifell_Lovell_1999,percol = 1,dmus = 2,inputs = 3,outputs = 4,arrangement = "vertical")

result_fgnz <- malmquist_index(data_example,orientation = "oo",rts = "vrs",type1 = "cont",type2 = "fgnz")
mi_fgnz <- result_fgnz$mi

result_rd <- malmquist_index(data_example,orientation = "oo",rts = "vrs",type1 = "cont",type2 = "rd")
mi_rd <- result_rd$mi

result_gl <- malmquist_index(data_example,orientation = "oo",rts = "vrs",type1 = "cont",type2 = "gl")
mi_gl <- result_gl$mi



# Example 2. If you have a dataset in long format.
data("EconomyLong")

head(EconomyLong)
##        DMUs Period  Capital  Labor     GIOV
## 1   Beijing   2005 12829.79 116.97  6946.07
## 2   Tianjin   2005  6347.92 122.17  6774.10
## 3     Hebei   2005  9473.70 292.21 11008.12
## 4  Shanxi_1   2005  7045.09 213.20  4850.91
## 5 Neimenggu   2005  4595.89  83.70  2995.59
## 6  Liaoning   2005 11902.12 276.55 10814.51
# Cho nhiều giai đoạn (Dữ liệu panel)
solieu <-EconomyLong
i <-as.matrix(solieu[,1])
t <-as.matrix(solieu[,2])
x <-as.matrix(solieu[,3:4])
y <-as.matrix(solieu[,5])
malmquist(X=x, Y=y, ID=i, TIME=t, RTS = "vrs", ORIENTATION = "in") ->m2
## Period  2 
## Period  3 
## Period  4 
## Period  5
names(m2)
## [1] "m"    "tc"   "ec"   "id"   "time" "e00"  "e10"  "e11"  "e01"