R/PF_eig.R

Defines functions PF_eig

Documented in PF_eig

#' @export

# Compute the PF eigenvalue and eigenvector.
PF_eig <- function(M) {
  ev <- eigen(M)

  tmp <- Re(ev$values)

  indx <- which(tmp == max(tmp))
  if (length(indx) != 1) {
    print(M)
    print(ev$values)
    print(indx)
    stop("Li:PF_eig, none or multiple PF eig value")
  }

  PFVector <- ev$vectors[, indx]
  PFVector <- PFVector / sum(PFVector)
  list(val = abs(ev$values[indx]), vec = abs(PFVector))
}

Try the CGE package in your browser

Any scripts or data that you put into this service are public.

CGE documentation built on March 26, 2020, 8 p.m.