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)
x2 <- matrix(c(13, 26, 15, 60 ),ncol=1)
y2 <- matrix(c(7, 9, 10, 15 ),ncol=1)
dea.plot(x0, y0, RTS="vrs", txt=TRUE)
dea.plot(x1, y1, RTS="vrs", add=TRUE, col="red")
dea.plot(x2, y2, RTS="vrs", add=TRUE, col="blue")
points(x1, y1, col="red", pch=16)
# points(x2, y2, col="blue", pch=17)
text(x1, y1, 1:dim(x1)[1], col="red", adj=-1)
text(x2, y2, 1:dim(x1)[1], col="blue", adj=-1)
legend("bottomright", legend=c("Period 0", "Period 1", "Period 2"),
col=c("black", "red", "blue"), lty=1, pch=c(1,16, 17), bty="n")
X <- rbind(x0, x1, x2)
Y <- rbind(y0, y1, y2)
# Make ID and TIME variables one way or another
ID <- rep(1:dim(x1)[1], 3)
# TIME <- c(rep(0,dim(x1)[1]), rep(1,dim(x1)[1]), rep(2,dim(x1)[1]))
TIME <- gl(3, dim(x1)[1], labels=0:2)
# This is how the data for Malmquist must look like
data.frame(TIME, ID, X, Y)
mq <- malmquist(X,Y, ID, TIME=TIME)
data.frame(TIME, ID, X, Y, mq$e00, mq$e01, mq$e10, mq$e11, mq$m, mq$tc)[order(ID, TIME),]
# How to make the Malmquist indices to a chain index
# Make data.frame with indices
DM <- data.frame(TIME, ID, m=mq$m, tc=mq$tc, ec=mq$ec)
# Set missing index for first period to 1, the base
DM[DM$TIME==0, c("m","tc", "ec")] <- 1
# Make chain index of the individual indices
AD <- aggregate(cbind(m=DM$m), by=list(ID=DM$ID), cumprod)
# Compare chain index to original index
data.frame(ID, TIME, m=c(AD$m), DM$m)
Run the code above in your browser using DataLab