R/mpm.R

mpm <- function(io){
  # Preliminaries
  if(class(io) != "InputOutput") stop('io should be of "InputOutput" class. See ?as.inputoutput')
  L <- io$L
  X <- io$X
  ####################
  ## Let's do this! ##
  ####################
  n <- length(X)
  one <- matrix(1, nrow = n)
  V <- t(one) %*% L %*% one
  Vinv <- matrix(1/V, ncol = n, nrow = n)
  Lcol <- L %*% one
  Lrow <- t(one) %*% L
  M <- Vinv * (Lcol %*% Lrow)
  M
}
jjpwade/ioanalysis documentation built on May 6, 2019, 6:57 p.m.