R/RcppExports.R

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' Do the GRAS algorithm for updating matrizes
#'
#' This function calculates an updated matrix X, based on a matrix A,
#' which meets the given row and columns totals. Note: A can contain
#' negative elements.
#' @param A the "base" matrix
#' @param u column vector with the row totals
#' @param v row vector with the column totals
#' @param epsilon the error tolerance level, default is 1e-10.
#' @param maxiter maximum number of iterations, default is 10000.
#' @param verbose should some information of the iterations be
#'     displayed? Default is FALSE
#' @return the updated matrix X
#' @author Oliver Reiter
#' @references Junius T. and J. Oosterhaven (2003), The solution of
#'     updating or regionalizing a matrix with both positive and
#'     negative entries, Economic Systems Research, 15, pp. 87-96.
#'
#'     Lenzen M., R. Wood and B. Gallego (2007), Some comments on the
#'     GRAS method, Economic Systems Research, 19, pp. 461-465.
#'
#'     Temurshoev, U., R.E. Miller and M.C. Bouwmeester (2013), A note
#'     on the GRAS method, Economic Systems Research, 25, pp. 361-367.
#' @keywords gras, matrix updating
#' @examples
#' ## example from the papers
#' A <- matrix(c(7, 3, 5, -3, 2, 9, 8, 0, -2, 0, 2, 0),
#'             ncol = 4, nrow = 3, byrow = TRUE)
#' u <- c(15, 26, -1)
#' v <- c(9, 16, 17, -2)
#' doGRAS(A, u, v)
#' @export
doGRAS <- function(A, u, v, epsilon = 1e-10, maxiter = 1000L, verbose = FALSE) {
    .Call('_riot_doGRAS', PACKAGE = 'riot', A, u, v, epsilon, maxiter, verbose)
}

#' Do the SUTRAS algorithm for updating supply and use tables
#'
#' This function calculates an updated supply and (domestic and import) use
#' table (SUTs), based on a given SUT and national accounts data.
#' @param V the supply (make) matrix
#' @param Ud the domestic use matrix
#' @param Um the import use matrix
#' @param m0 the import vector
#' @param u_bar vector with the new intermediate input sums
#' @param x_bar vector with the new gross output sums
#' @param M scalar, new total imports
#' @param c vector with the negative entries of the trade margins, given in absolute values
#' @param epsilon the error tolerance level, default is 1e-10.
#' @param maxiter maximum number of iterations, default is 10000.
#' @param verbose should some information of the iterations be
#'     displayed? Default is FALSE
#' @return the updated SUTs, a list
#' @author Oliver Reiter
#' @references Temurshoev, U., & Timmer, M. P. (2011). Joint estimation of supply and use tables. Papers in Regional Science, 90(4), 863-882.
#' @keywords SUTRAS, input-output updating
#' @examples
#' data(TestSUTs_AUT2010)
#' data(TestNA_AUT2011)
#' c <- rep(0, length(m0))
#' res <- doSUTRAS(V = V, Ud = Ud, Um = Um, m0 = m0, u_bar = ubar,
#'                 x_bar = xbar, M = M, c = c, epsilon = 1e-10,
#'                 maxiter = 100, verbose = FALSE)
#' @export
doSUTRAS <- function(V, Ud, Um, m0, u_bar, x_bar, M, c, epsilon = 1e-10, maxiter = 1000L, verbose = FALSE) {
    .Call('_riot_doSUTRAS', PACKAGE = 'riot', V, Ud, Um, m0, u_bar, x_bar, M, c, epsilon, maxiter, verbose)
}

#' Invert a column vector
#'
#' @param x a vector
sinvc <- function(x) {
    .Call('_riot_sinvc', PACKAGE = 'riot', x)
}

#' Invert a row vector
#'
#' @param x a vector
sinvr <- function(x) {
    .Call('_riot_sinvr', PACKAGE = 'riot', x)
}

#' Update the inverse by column
#'
#' @param A an inverse of a matrix to be updated
#' @param u column vector
#' @param i row index
ShermanUpdateCol <- function(A, u, i) {
    invisible(.Call('_riot_ShermanUpdateCol', PACKAGE = 'riot', A, u, i))
}

#' Update the inverse by row
#'
#' @param A an inverse of a matrix to be updated
#' @param v row vector
#' @param i column index
ShermanUpdateRow <- function(A, v, i) {
    invisible(.Call('_riot_ShermanUpdateRow', PACKAGE = 'riot', A, v, i))
}

#' Return a vector of indices except index i
#'
#' @param i index not to be included
#' @param nm1 length of the vector
index_noti <- function(i, nm1) {
    .Call('_riot_index_noti', PACKAGE = 'riot', i, nm1)
}

#' Calculate random walk centrality
#'
#' Calculate random walk centrality of an input-output matrix
#' @param A the input-output matrix
#' @param verbose should some information of the iterations be
#'     displayed? Default is FALSE
#' @return a vector of centralities
#' @author Oliver Reiter
#' @references Blöchl F, Theis FJ, Vega-Redondo F, and Fisher E: Vertex Centralities in Input-Output Networks Reveal the Structure of Modern Economies, Physical Review E, 83(4):046127, 2011
#' @keywords input-output analysis
#' @export
rwCentrality <- function(A, verbose = FALSE) {
    .Call('_riot_rwCentrality', PACKAGE = 'riot', A, verbose)
}
zauster/riot documentation built on May 4, 2019, 9:12 p.m.