## R code to illustrate data envelopment analysis
## Install a DEA package. When asked to select a CRAN mirror,
## scroll down to find a nearby mirror, such as USA (MA).
[Link]("nonparaeff")
## Load the package
library(nonparaeff)
## Example 1: one output and one input
## Load data on DMUs' outputs and inputs. Putting the command in
parentheses
## causes the object created to be displayed.
(YXtable = [Link]("[Link]"))
## Make the variables in YXtable accessible to R
attach(YXtable)
## Plot the data
plot(x,y)
## prepare data for use by nonparaeff (outputs listed before inputs)
[Link] = [Link](y, x)
## Assuming a free disposal hull (fdh), implement an input-oriented analysis
## (orientation 1).
(fdhio11 = fdh([Link], noutput=1, orientation=1))
## Still assuming a free disposal hull, implement an output-oriented analysis
## (orientation 2).
(fdhoo11 = fdh([Link], noutput=1, orientation=2))
## With the output-orientation, nonparaeff calculates the factor by which
## a DMU could increase its output without needing additional inputs. The
## reciprocal of this factor is output-oriented technical efficiency.
1/fdhoo11
## Assuming a convex hull with variable returns to scale (rts=2), implement
an
## input-oriented analysis.
(vrio11 = dea([Link], noutput=1, orientation=1, rts=2))
## In table printed by the preceding command, eff is pure input-oriented
## technical efficiency. (It is pure in the sense of measuring efficiency
## conditional on the scale of production--that is, ignoring any
## inefficiency due to scale.
## Still assuming variable returns to scale, do an output-oriented analysis.
(vroo11 = dea([Link], noutput=1, orientation=2, rts=2))
1/vroo11$eff
## Assuming constant returns to scale (rts=1), do an input-oriented analysis.
(crio11 = dea([Link], noutput=1, orientation=1, rts=1))
## Maintaining the CRS assumption, do an output-oriented analysis.
(croo11 = dea([Link], noutput=1, orientation=2, rts=1))
1/croo11$eff
## Calculate input-oriented scale efficiency.
(seio11 = crio11$eff/vrio11$eff)
## Calculate output-oriented scale efficiency.
(seoo11 = (1/croo11$eff)/(1/vroo11$eff))
## Example 2: one output and two inputs
## Load data on DMUs' outputs and inputs.
(QKLtable = [Link]("[Link]"))
## Make the variables in YXtable accessible to R
attach(QKLtable)
## prepare data for use by nonparaeff (outputs listed before inputs)
[Link] = [Link](Q, K, L)
## ## Assuming a convex hull with variable returns to scale, implement an
## input-oriented analysis.
(vrio12 = dea([Link], noutput=1, orientation=1, rts=2))
## Example 3: two outputs and two inputs
## Load data on DMUs' outputs and inputs
(YZKLtable = [Link]("[Link]"))
attach(YZKLtable)
## prepare data for use by nonparaeff (outputs listed before inputs)
[Link] = [Link](Y, Z, K, L)
## ## Assuming a convex hull with constant returns to scale, implement an
## input-oriented analysis.
(crio22 = dea([Link], noutput=2, orientation=1, rts=1))