Learn R Programming

SdeaR (version 1.0.2)

make_deadata_stoch: make_deadata_stoch

Description

This function creates, from a deadata object, a deadata_stoch object by adding the corresponding covariance matrices. These objects are prepared to be passed to a modelstoch_* function.

We consider \(\mathcal{D}=\left\{ \textrm{DMU}_1, \ldots ,\textrm{DMU}_n \right\} \) a set of \(n\) DMUs with \(m\) stochastic inputs and \(s\) stochastic outputs. Matrices \(\tilde{X}=(\tilde{x}_{ij})\) and \(\tilde{Y}=(\tilde{y}_{rj})\) are the input and output data matrices, respectively, where \(\tilde{x}_{ij}\) and \(\tilde{y}_{rj}\) represent the \(i\)-th input and \(r\)-th output of the \(j\)-th DMU. Moreover, we denote by \(X=(x_{ij})\) and \(Y=(y_{rj})\) their expected values. We suppose that \(\tilde{x}_{ij}\) and \(\tilde{y}_{rj}\) follow a multivariate probability distribution with means \(E(\tilde{x}_{ij})=x_{ij}\), \(E(\tilde{y}_{rj})=y_{rj}\) and covariance matrix $$\Delta = \begin{pmatrix} \Delta ^{II}_{11} & \cdots & \Delta ^{II}_{1m} & \Delta ^{IO}_{11} & \cdots & \Delta ^{IO}_{1s} \\ \vdots & & \vdots & \vdots & & \vdots \\ \Delta ^{II}_{m1} & \cdots & \Delta ^{II}_{mm} & \Delta ^{IO}_{m1} & \cdots & \Delta ^{IO}_{ms} \\ \\ \Delta ^{OI}_{11} & \cdots & \Delta ^{OI}_{1m} & \Delta ^{OO}_{11} & \cdots & \Delta ^{OO}_{1s} \\ \vdots & & \vdots & \vdots & & \vdots \\ \Delta ^{OI}_{s1} & \cdots & \Delta ^{OI}_{sm} & \Delta ^{OO}_{s1} & \cdots & \Delta ^{OO}_{ss} \\ \end{pmatrix}_{n(m+s)\times n(m+s)}$$ where \(\Delta ^{II}_{ik}\), \(\Delta ^{OO}_{rp}\), \(\Delta ^{IO}_{ir}\) and \(\Delta ^{OI}_{ri}\) are \(n\times n\) matrices, for \(1\leq i,k\leq m\) and \(1\leq r,p\leq s\), such that $$\left( \Delta ^{II}_{ik}\right) _{jq}=\mathrm{Cov}(\tilde{x}_{ij}, \tilde{x}_{kq}),$$ $$\left( \Delta ^{OO}_{rp}\right) _{jq}=\mathrm{Cov}(\tilde{y}_{rj}, \tilde{y}_{pq}),$$ $$\left( \Delta ^{IO}_{ir}\right) _{jq}=\left( \Delta ^{OI}_{ri}\right) _{qj} =\mathrm{Cov}(\tilde{x}_{ij}, \tilde{y}_{rq}),$$ with \(1\leq j,q\leq n\).

- If we have the covariances matrix in the general form above, it can be introduced directly by parameter cov_matrix. Since this matrix is supposed to be symmetric, only values above the diagonal are read, ignoring values below the diagonal.

- Alternatively, we can introduce the covariances matrix using parameters cov_II, cov_OO and cov_IO, that are 4-dimensional arrays of size \(m\times m\times n\times n\), \(s\times s\times n\times n\) and \(m\times s\times n\times n\), respectively, such that $$\texttt{cov\_II[i, k, , ]}=\Delta ^{II}_{ik},$$ $$\texttt{cov\_OO[r, p, , ]}=\Delta ^{OO}_{rp},$$ $$\texttt{cov\_IO[i, r, , ]}=\Delta ^{IO}_{ir},$$ for \(1\leq i,k\leq m\) and \(1\leq r,p\leq s\). Since matrices \(\Delta ^{II}_{ii}\) and \(\Delta ^{OO}_{rr}\) are supposed to be symmetric, only values above the diagonal are read, ignoring values below the diagonal. Moreover, since \(\Delta ^{II}_{ki}\) is the transpose of \(\Delta ^{II}_{ik}\), and \(\Delta ^{OO}_{pr}\) is the transpose of \(\Delta ^{OO}_{rp}\), only matrices \(\Delta ^{II}_{ik}\) and \(\Delta ^{OO}_{rp}\) with \(i\leq k\) and \(r\leq p\) are necessary, ignoring those with \(i>k\) and \(r>p\).

- If covariances between different inputs/outputs are zero, we can make use of parameters cov_input and cov_output, that are arrays of size \(m\times n\times n\) and \(s\times n\times n\), respectively, such that $$\texttt{cov\_input[i, , ]}=\Delta ^{II}_{ii},$$ $$\texttt{cov\_output[r, , ]}=\Delta ^{OO}_{rr},$$ for \(1\leq i\leq m\) and \(1\leq r\leq s\). By symmetry of \(\Delta ^{II}_{ii}\) and \(\Delta ^{OO}_{rr}\), only values above the diagonal are read, ignoring values below the diagonal.

- Finally, if all the variables are independent then the covariances matrix is diagonal. Hence, we might use parameters var_input and var_output, that are matrices of size \(m\times n\) and \(s\times n\), respectively, such that $$\texttt{var\_input[i, j]}=\mathrm{Var}\left( \tilde{x}_{ij}\right) ,$$ $$\texttt{var\_output[r, j]}=\mathrm{Var}\left( \tilde{y}_{rj}\right) ,$$ for \(1\leq i\leq m\), \(1\leq r\leq s\) and \(1\leq j\leq n\).

Usage

make_deadata_stoch(datadea = NULL,
          var_input = NULL,
          var_output = NULL,
          cov_input = NULL,
          cov_output = NULL,
          cov_II = NULL,
          cov_OO = NULL,
          cov_IO = NULL,
          cov_matrix = NULL)

Value

An object of class deadata_stoch.

Arguments

datadea

The deadata object.

var_input

A matrix of size m x n, where m is the number of inputs and n is the number of DMUs. It contains the variances of each input of each DMU, such that var_input[i, j] is the variance of the input i of DMU j. Use this parameter if all covariances are 0.

var_output

A matrix of size s x n, where s is the number of outputs and n is the number of DMUs. It contains the variances of each output of each DMU, such that var_output[r, j] is the variance of the output r of DMU j. Use this parameter if all covariances are 0.

cov_input

An array of size m x n x n containing the covariances of each input between DMUs, such that cov_input[i, j, k] is the covariance between the input i of DMU j and the input i of DMU k. The corresponding variances are in the diagonal of each n x n submatrix. Since these submatrices are supposed to be symmetric, only values above the diagonal are read in order to reconstruct the symmetric submatrices, ignoring values below the diagonal. Use this parameter if covariances between different inputs are 0.

cov_output

An array of size s x n x n containing the covariances of each output between DMUs, such that cov_output[r, j, k] is the covariance between the output r of DMU j and the output r of DMU k. The corresponding variances are in the diagonal of each n x n submatrix. Since these submatrices are supposed to be symmetric, only values above the diagonal are read in order to reconstruct the symmetric submatrices, ignoring values below the diagonal. Use this parameter if covariances between different outputs are 0.

cov_II

An array of size m x m x n x n containing the covariances between inputs and between DMUs, such that cov_II[i1, i2, j, k] is the covariance between the input i1 of DMU j and the input i2 of DMU k. For the input i, the corresponding variances are in the diagonal of the n x n submatrices of the form cov_II[i, i, , ]. Since these submatrices are supposed to be symmetric, only values above the diagonal are read in order to reconstruct the symmetric submatrices, ignoring values below the diagonal. Moreover, since cov_II[i2, i1, , ] is the transpose of cov_II[i1, i2, , ], only submatrices cov_II[i1, i2, , ] with i1 <= i2 are necessary, ignoring those with i1 > i2. Use this parameter if covariances between inputs are nonzero.

cov_OO

An array of size s x s x n x n containing the covariances between outputs and between DMUs, such that cov_OO[r1, r2, j, k] is the covariance between the output r1 of DMU j and the output r2 of DMU k. For the output r, the corresponding variances are in the diagonal of the n x n submatrices of the form cov_OO[r, r, , ]. Since these submatrices are supposed to be symmetric, only values above the diagonal are read in order to reconstruct the symmetric submatrices, ignoring values below the diagonal. Moreover, since cov_OO[r2, r1, , ] is the transpose of cov_OO[r1, r2, , ], only submatrices cov_OO[r1, r2, , ] with r1 <= r2 are necessary, ignoring those with r1 > r2. Use this parameter if covariances between outputs are nonzero.

cov_IO

An array of size m x s x n x n containing the covariances between inputs and outputs, and between DMUs, such that cov_IO[i, r, j, k] is the covariance between the input i of DMU j and the output r of DMU k. Use this parameter if covariances between inputs and outputs are nonzero.

cov_matrix

A matrix of size n(m+s) x n(m+s) following the notation of Cooper et al. (1998). Since this matrix is supposed to be symmetric, only values above the diagonal are read, ignoring values below the diagonal.

Author

Vicente Bolós (vicente.bolos@uv.es). Department of Business Mathematics

Rafael Benítez (rafael.suarez@uv.es). Department of Business Mathematics

Vicente Coll-Serrano (vicente.coll@uv.es). Quantitative Methods for Measuring Culture (MC2). Applied Economics.

University of Valencia (Spain)

References

Cooper, W.W.; Huang, Z.; Lelas, V.; Li, S.X.; Olesen, O.B. (1998). “Chance Constrained Programming Formulations for Stochastic Characterizations of Efficiency and Dominance in DEA", Journal of Productivity Analysis, 9, 53-79.

Land, K.C; Lovell, C.A.K.; Thore, S. (1993). "Chance-constrained data envelopment analysis", Managerial and Decision Economics, Vol. 14, No. 6, 541-554.

Examples

Run this code
# Example 1
library(deaR)
data("Coll_Blasco_2006")
ni <- 2 # number of inputs
no <- 2 # number of outputs
data_example <- make_deadata(datadea = Coll_Blasco_2006,
                             ni = ni,
                             no = no)
nd <- length(data_example$dmunames) # number of DMUs
# All variances are 1.
var_input <- matrix(1, nrow = ni, ncol = nd)
var_output <- matrix(1, nrow = no, ncol = nd)
data_stoch <- make_deadata_stoch(datadea = data_example,
                                 var_input = var_input,
                                 var_output = var_output)
# All covariances are 1.
cov_input <- array(1, dim = c(ni, nd, nd))
cov_output <- array(1, dim = c(no, nd, nd))
data_stoch2 <- make_deadata_stoch(datadea = data_example,
                                  cov_input = cov_input,
                                  cov_output = cov_output)

# Example 2. Deterministic data with one stochastic input.
library(deaR)
dmunames <- c("A", "B", "C")
nd <- length(dmunames) # Number of DMUs
inputnames <- c("Input_1", "Input_2")
ni <- length(inputnames) # Number of Inputs
outputnames <- c("Output_1", "Output_2", "Output_3")
no <- length(outputnames) # Number of Outputs
X <- matrix(c(5, 14, 8, 15, 7, 12),
            nrow = ni, ncol = nd, dimnames = list(inputnames, dmunames))
Y <- matrix(c(9, 4, 16, 5, 7, 10, 4, 9, 13),
            nrow = no, ncol = nd, dimnames = list(outputnames, dmunames))
datadea <- make_deadata(inputs = X,
                        outputs = Y)
covX <- array(0, dim = c(2, 3, 3))
# The 2nd input is stochastic.
# Since the corresponding 3x3 covariances matrix is symmetric, only values
# above the diagonal are necessary.
covX[2, 1, ] <- c(1.4, 0.9, 0.6)
covX[2, 2, 2:3] <- c(1.5, 0.7)
covX[2, 3, 3] <- 1.2
# Alternatively (note that values below the diagonal are ignored).
covX[2, , ] <- matrix(c(1.4, 0.9, 0.6, 0, 1.5, 0.7, 0, 0, 1.2),
                      nrow = 3,
                      byrow = TRUE)
datadea_stoch <- make_deadata_stoch(datadea,
                                    cov_input = covX)

# Example 3. Replication of Program Follow Through data in Land et al. (1993)
library(deaR)
data("PFT1981")
# Selecting DMUs in Program Follow Through (PFT)
PFT <- PFT1981[1:49, ]
PFT <- make_deadata(PFT,
                    inputs = 2:6,
                    outputs = 7:9)
c <- 0.5
var_output <- matrix(c^2, nrow = 3, ncol = 49)
PFT_stoch <- make_deadata_stoch(datadea = PFT, var_output = var_output)

# Example 4. 5 random observations of 3 DMUs with 2 inputs and 2 outputs.
library(deaR)
# Generate random observations.
input1 <- data.frame(I1D1 = rnorm(5, mean = sample(5:10, 1)),
                     I1D2 = rnorm(5, mean = sample(5:10, 1)),
                     I1D3 = rnorm(5, mean = sample(5:10, 1)))
input2 <- data.frame(I2D1 = rnorm(5, mean = sample(5:10, 1)),
                     I2D2 = rnorm(5, mean = sample(5:10, 1)),
                     I2D3 = rnorm(5, mean = sample(5:10, 1)))
output1 <- data.frame(O1D1 = rnorm(5, mean = sample(5:10, 1)),
                      O1D2 = rnorm(5, mean = sample(5:10, 1)),
                      O1D3 = rnorm(5, mean = sample(5:10, 1)))
output2 <- data.frame(O2D1 = rnorm(5, mean = sample(5:10, 1)),
                      O2D2 = rnorm(5, mean = sample(5:10, 1)),
                      O2D3 = rnorm(5, mean = sample(5:10, 1)))
# Generate deadata with means of observations.
inputs <- matrix(mapply(mean, cbind(input1, input2)),
                 nrow = 2,
                 ncol = 3,
                 byrow = TRUE,
                 dimnames = list(c("I1", "I2"), c("D1", "D2", "D3")))
outputs <- matrix(mapply(mean, cbind(output1, output2)),
                  nrow = 2,
                  ncol = 3,
                  byrow = TRUE,
                  dimnames = list(c("O1", "O2"), c("D1", "D2", "D3")))
datadea <- make_deadata(inputs = inputs,
                        outputs = outputs)
# Generate covariances matrix cov_matrix.
cov_matrix <- cov(cbind(input1, input2, output1, output2))
# Generate deadata_stoch
datadea_stoch <- make_deadata_stoch(datadea,
                                    cov_matrix = cov_matrix)

Run the code above in your browser using DataLab