Thibault LAURENT
Introduction
Introduction
Simulation with R
1. Factor variable
Random generation of a vector of size 100 following a binomial
distribution with p = 0.2:
> x <- rbinom(100, 1, 0.2)
> plot(table(x), main = "frequency")
Other distributions: Poisson P() (function rpois), etc.
2. Numeric variable
Random generation of a vector of size 100 following a gaussian
distribution N ( = 1, = 1):
> x <- rnorm(100, 1, 1)
> hist(x, main = "")
Other distributions: Uniform U[a,b] (function runif), etc.
Representation of the
simulated data:
1.0
> plot(y ~ x, type = "p",
+ col = "red", ylim = c(0,
0.8
+ 1))
0.6
0.4
Representation of the true
0.2
frontier:
0.0
> x.seq <- seq(0, 1, by = 0.01) 0.2 0.4 0.6 0.8
x
> t.fr <- x.seq^(1/2)
> lines(t.fr ~ x.seq, col = "blue")
Reproducible research
> require(xtable)
> tab1 <- data.frame(lambda, theta, delta)
> matable <- xtable(tab1[1:5, ], digits = 3, align = "l|ccc",
+ caption = "True Frontier Efficiency measures")
> print(matable, hline.after = c(0), file = "V.tex",
+ size = "tiny")
1.0
> res.lm <- lm(y ~ x)
0.8
> beta.lm <- coefficients(res.lm) 3
0.6
0.4
0.2
0.0
1.0
> plot(y ~ x, type = "p", true
stoch
0.8
+ col = "red", ylim = c(0,
0.6
+ 1))
y
> lines(t.fr ~ x.seq, col = "blue")
0.4
0.2
+ col = "blue", lty = 2)
0.0
> legend("topleft", legends = c("true", 0.2 0.4 0.6 0.8
x
+ "stoch"), lty = 1:2,
+ col = "blue")
Let us define f1 : x 0 + x
> f1 = function(x) alpha2 + beta.lm[2] * x
x0
f11 : x
> f1.inv = function(x) (x - alpha2)/beta.lm[2]
0.7
DEA
FDH
> identify(x, y)
0.6
0.5
+ y[c(2, 9, 3, 4)])
0.4
> lines(x[c(2, 12, 12,
0.3
+ 9, 9, 8, 8, 3, 3,
+ 12, 12, 9, 9, 8, x
+ 8, 3, 3, 4)], lty = 2)
> legend("topleft", legend = c("DEA",
+ "FDH"), lty = 1:2)
0.7
0.6
0.5
y
0.4
0.3
2. Using this position on the
x
0.6 0.8
Naive Bootstrap
Repeat B times (with the loop
for)
1. sampling among the 15
observations with function
0.7
sample
0.6
0.5
y[index]
of the frontiers
0.4
0.3
3. calculate new measures of
x[index]
0.6 0.7
Introduction
10000
10000
8000
8000
6000
6000
output
output
y
y
4000
4000
2000
2000
0
0
0 200 400 600 800 1000 1200 1400 0 1000 2000 3000 4000
x1 x2
input 1 input 2
x3
25000
+ x2, y))
20000
15000
10000
5000
0
0 1000 2000 3000 4000 5000
x2
Measures of efficiency
> require(FEAR)
FEAR (Frontier Efficiency Analysis with R) 1.13 installed
Copyright Paul W. Wilson 2010
See file LICENSE for license and citation information
> res.dea <- dea(input, output, ORIENTATION = 2)
> res.fdh <- fdh(input, output, ORIENTATION = 2)
> res.orderm <- orderm(input, output, ORIENTATION = 2)
> res.hquan <- hquan(input, output, ORIENTATION = 2)
> res.measures <- rbind(res.dea, res.fdh[1, ], res.orderm[1, ],
+ res.hquan)
> row.names(res.measures) <- c("dea", "fdh", "orderm", "al-quan")
You can use the functions order or sort to compute the ranks of
the firms depending on the efficiency measure.
4
+ col = colors()[100], dea
fdh
orderm
+ lty = 2) alquan
3
> lines(density(res.orderm),
Density
2
+ col = colors()[101],
1
+ lty = 3)
> lines(density(res.hquan),
0
+ col = colors()[102], 0.5 0.0 0.5 1.0 1.5 2.0
N = 61 Bandwidth = 0.08351
+ lty = 4)
> legend("topleft", legend = c("dea",
+ "fdh", "order-m",
+ "al-quan"), lty = 1:4,
+ col = colors()[99:102])
Thibault LAURENT Toulouse School of Economics
Frontier Analysis with R
Introduction A first simulated example Analysis of the real data
Bootstrap