R还真可以作线性规划,下面给出一个用R语言的lpSolve包来解决一个简单的线性规划问题
target: max C = 5*x1 + 8*x2
subject to:
x1 + x2 <= 2
x1 + 2*x2 = 3
x1,x2 >=0
代码——
library(lpSolve)
eg.lp <- lp(objective.in=c(5, 8),
const.mat=matrix(c(1, 1, 1, 2), nrow=2),
const.rhs=c(2, 3),
const.dir=c("<=", "="), direction="max")
eg.lp$solution
求解为1,1
做DEA需要FEAR包里的dea()
data(ccr)
x=matrix(nrow=5,ncol=70)
x[1,]=ccr$x1
x[2,]=ccr$x2
x[3,]=ccr$x3
x[4,]=ccr$x4
x[5,]=ccr$x5
y=matrix(nrow=3,ncol=70)
y[1,]=ccr$y1
y[2,]=ccr$y2
y[3,]=ccr$y3
data(ccr)
x=t(matrix(c(ccr$x1,ccr$x2,ccr$x3,ccr$x4,ccr$x5),nrow=70,ncol=5))
y=t(matrix(c(ccr$y1,ccr$y2,ccr$y3),nrow=70,ncol=3))
dhat=dea(XOBS=x,YOBS=y)
FEAR不好装,基本都会装崩溃掉,下载下来直接打散copy到lib算了...