File: gmWA.R

package info (click to toggle)
r-cran-ctmcd 1.4.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,384 kB
  • sloc: cpp: 183; ansic: 19; makefile: 2
file content (14 lines) | stat: -rw-r--r-- 486 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
gmWA <-
function (tmrel, te, logmethod = "Eigen") 
{
    n = nrow(tmrel)
    gmest = logm(tmrel, method = logmethod)/te
    for (i in 1:(n - 1)) {
        gmiNeg = -sum((gmest * (gmest < 0))[i, setdiff(1:n, i)])
        gmiPos = sum((gmest * (gmest > 0))[i, ])
        gmest[i, setdiff(1:n, i)] = gmest[i, setdiff(1:n, i)] - 
            gmiNeg/gmiPos * abs(gmest[i, setdiff(1:n, i)])
    }
    gmest[setdiff(which(gmest < 0), seq(1, n^2, n + 1))] = 0
    return(gmest)
}