Skip to content

Commit

Permalink
version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderOe authored and cran-robot committed Mar 19, 2024
1 parent d662a97 commit 5183cb9
Show file tree
Hide file tree
Showing 16 changed files with 900 additions and 299 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: hyperbolicDEA
Title: Hyperbolic DEA Estimation
Version: 0.1.1
Version: 1.0.0
Authors@R: c(
person("Alexander", "Öttl", , "alexoettl34@gmail.com", role = c("cre", "aut"),
comment = c(ORCID = "0000-0002-0734-4135")),
Expand All @@ -16,8 +16,8 @@ Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.2.3
NeedsCompilation: no
Packaged: 2024-02-21 12:28:23 UTC; fkg114
Packaged: 2024-03-18 16:57:34 UTC; fkg114
Author: Alexander Öttl [cre, aut] (<https://orcid.org/0000-0002-0734-4135>),
Daniel Gulde [aut]
Repository: CRAN
Date/Publication: 2024-02-22 20:20:03 UTC
Date/Publication: 2024-03-18 17:30:07 UTC
26 changes: 15 additions & 11 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
d7f9a76f9ebd9f4ec1f5d6c6f783345e *DESCRIPTION
f72375bffd457cb3fe5117eed9b9d8f0 *DESCRIPTION
7420c3435de96c603a7eac5974e3ad63 *LICENSE
c581dc6070df1c1f2ede2c134dcf3e5c *NAMESPACE
5e4bae93b128521236d3f65a103c7a48 *R/costDEA.R
7a5e183093294fd45ccce42f16305923 *R/hyperbolicDEA.R
9a1bfa1b34f83cbff9affe2afb55718a *R/lprofitDEA.R
4a944f9d71399c98794a6456d8679a90 *R/nlprofitDEA.R
40d288bb253f218da700a696ab844b8e *NAMESPACE
f431ca48123e257e4df594362349b979 *R/check_arguments.R
3fd393a145c4f09922dfb8c4ccfdb803 *R/costDEA.R
ca59a30e41c94608ba12ec8818db485a *R/hyperbolicDEA.R
94478f63edbcb40cdab42a6f488cceb6 *R/lprofitDEA.R
bb6ae3c0c6f9e60b8294856ad30c6080 *R/nlprofitDEA.R
c0be7b6dc48e621146ab64b145af7d1b *R/slack.R
7590bcef71201e0535bdfe9405280ae4 *R/wrDEA.R
49322e18bc98f2e01f48873107d43f6b *README.md
75a4f572ac6ed3c7f7cb50b6f3b2a934 *man/costDEA.Rd
5301a3ef1a0dcf4b6f77e64099c72a20 *man/hyperbolicDEA.Rd
da825138fe98080f7706cd658623d31a *man/lprofitDEA.Rd
e1abb9bbf539f08fff7a570f5a2461e9 *man/nlprofitDEA.Rd
2c2a5c42b855f23499c159842bffe2a9 *man/costDEA.Rd
de66a1215cef333db63c1f1c93b96867 *man/hyperbolicDEA.Rd
33dfe4ebef753d02d8da9e22458bb6d5 *man/lprofitDEA.Rd
e4ccd6da57bb2111dc2be22d6ebca7ff *man/nlprofitDEA.Rd
153b2b504257309308a9f25cde35b062 *man/wrDEA.Rd
5eb9c7385ddd9a0f93218d310178b677 *tests/testthat.R
138e001fe5d422d50412e43b8b89fbd8 *tests/testthat/test-hyperbolicDEA.R
4af076af8dd051d1e74bb66bbc4a2e6e *tests/testthat/test-hyperbolicDEA.R
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export(costDEA)
export(hyperbolicDEA)
export(lprofitDEA)
export(nlprofitDEA)
export(wrDEA)
import(Benchmarking)
import(doParallel)
import(dplyr)
Expand Down
69 changes: 69 additions & 0 deletions R/check_arguments.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
check_arguments <- function(X, Y, XREF = NULL, YREF = NULL,
WR = NULL, RTS = "vrs",
NONDISC_IN = NULL, NONDISC_OUT = NULL,
ALPHA = NULL, ORIENTATION = NULL){

# General checks for all functions in the package
if (!is.matrix(X) && !is.data.frame(X) && !is.numeric(X)){
stop("X must be a numeric vector, matrix or dataframe")
}
if (!is.matrix(Y) && !is.data.frame(Y) && !is.numeric(Y)){
stop("Y must be a numeric vector, matrix or dataframe")
}

if (!is.null(WR)){
if (!is.matrix(WR) && !is.data.frame(WR)){
WR <- t(as.matrix(WR))
}
if (ncol(WR) != ncol(as.matrix(X)) + ncol(as.matrix(Y))){
stop("WR must be a matrix of weight restrictions in standard form,
ncol(WR) = ncol(Y) + ncol(X)")
}
}
if (!is.null(XREF)&&!is.null(YREF)){
if (!is.matrix(XREF) && !is.data.frame(XREF) && !is.numeric(XREF)){
stop("XREF must be a numeric vector, matrix or dataframe")
}
if (!is.matrix(YREF) && !is.data.frame(YREF) && !is.numeric(YREF)){
stop("YREF must be a numeric vector, matrix or dataframe")
}
if ((ncol(as.matrix(YREF))+ncol(as.matrix(XREF))) != (ncol(as.matrix(X)) + ncol(as.matrix(Y)))){
stop("XREF and YREF must be the same input-output combination:
ncol(XREF) = ncol(X); ncol(YREF) = ncol(Y)")
}
}
if (anyNA(X) || anyNA(Y) || anyNA(XREF) || anyNA(YREF) || anyNA(WR) ||
any(is.nan(X)) || any(is.nan(Y)) || any(is.nan(XREF)) ||
any(is.nan(YREF)) || any(is.nan(WR))) {
stop("The optimizer cannot handle missing or NaN values.")
}

possible_rts <- c("crs", "vrs", "ndrs", "nirs", "fdh")
RTS <- tolower(RTS)
if (!(RTS %in% possible_rts)){
stop("Unknown scale of returns:", RTS)
}
if (!is.null(ALPHA)){
if (ALPHA < 0 || ALPHA > 1){
warning("ALPHA should be a number between 0 and 1 otherwise inputs can be increased
or outputs can be decreased")
}
}
if (!is.null(ORIENTATION)){
ORIENTATION <- tolower(ORIENTATION)
if (!(ORIENTATION %in% c("in", "out"))){
stop("ORIENTATION must be either 'in' or 'out'")
}
}
if (!is.null(NONDISC_IN)){
if (!(all(NONDISC_IN %in% 1:ncol(as.matrix(X))))){
stop("NONDISC_IN must be an available index of the input matrix")
}
}
if (!is.null(NONDISC_OUT)){
if (!(all(NONDISC_OUT %in% 1:ncol(as.matrix(Y))))){
stop("NONDISC_OUT must be an available index of the output matrix")
}
}

}
27 changes: 15 additions & 12 deletions R/costDEA.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#' @title Cost DEA model
#' @description Cost DEA model optimizing the input allocation with given prices.
#' It returns the estimated lambdas as well as the optimal values for inputs.
#' It returns the estimated lambdas as well as the optimal values for inputs and a cost efficiency score
#' that is the ratio of optimal costs over observed costs.
#'
#' @seealso [Benchmakring::cost.opt] for a similar function
#' @seealso [Benchmarking::cost.opt] for a similar function
#'
#' @param X Matrix or dataframe with DMUS as rows and inputs as columns
#' @param Y Matrix or dataframe with DMUs as rows and outputs as columns
#' @param pX Matrix or dataframe with prices for each DMU and input.
#' Therefore it mus have the same dimensions as X.
#' @param RTS Character string indicating the returns-to-scale, e.g. "crs", "vrs"
#' @return A list object containing cost optimal inputs and lambdas indiceting
#' the the peer for optimal input allocation. Additionally, it returns the cost
#' efficiency as the ratio of the optimal cost to the observed cost.
#' @param X Vector, matrix or dataframe with DMUs as rows and inputs as columns
#' @param Y Vector, matrix or dataframe with DMUs as rows and outputs as columns
#' @param pX Vector, matrix or dataframe with prices for each DMU and input.
#' Therefore it must have the same dimensions as X.
#' @param RTS Character string indicating the returns-to-scale, e.g. "crs", "vrs".
#'
#' @return A list object containing the following:
#' \item{lambdas}{Estimated values for the composition of the respective Benchmarks. The lambdas are stored in a matrix with dimensions nrow(X) x nrow(X), where the row is the DMU under observation and the columns are the peers used for the Benchmark.}
#' \item{opt_value}{Optimal inputs.}
#' \item{cost_eff}{Cost efficiency as the ratio of the optimal cost to the observed cost.}
#' @examples
#' X <- matrix(c(1,2,3,3,2,1,2,2), ncol = 2)
#' Y <- matrix(c(1,1,1,1), ncol = 1)
Expand All @@ -24,7 +27,7 @@
#' @import lpSolveAPI
#' @export

costDEA <- function(X, Y, pX, RTS = "vrs") {
costDEA <- function(X, Y, pX, RTS = "crs") {

# Check arguments given by user
if (!is.matrix(X) && !is.data.frame(X) && !is.numeric(X)){
Expand Down Expand Up @@ -112,7 +115,7 @@ costDEA <- function(X, Y, pX, RTS = "vrs") {

}

colnames(lambdas) <- c(paste("Lambda",1:ncol(in_out_data),sep=""))
colnames(lambdas) <- c(paste("L",1:ncol(in_out_data),sep=""))
colnames(opt_value) <- c(paste("X",1:ncol(X),sep=""))

# Estimate cost efficiency
Expand Down

0 comments on commit 5183cb9

Please sign in to comment.