F5-mu.AND: Pairwise AND

Description Usage Arguments Value Algorithm Author(s) Examples

Description

mu.AND aggregates vectors of pairwise orderings created by mu.GE in a hierarchical fashion.

Usage

1
mu.AND(GE, frml=NULL)

Arguments

GE

matrix each column of which corresponds to one variable anddescribes pairwise orderings

frml

formula describing the hierarchical structure of the variables

Value

mu.AND returns a vector of the same length as the columns of GE, with information about pairwise orderings aggregated according to frml.

Algorithm

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
mu.AND <- function(GE, frml=NULL) {
  <\dots>
  if (is.null(frml)) {
    <\dots>
    GE  <- sq.array(GE)
    AND <- GE[,,1]^0
    nNA <- AND[,1]*0
    for (i in 1:dim(GE)[3]) {
      nNA <- nNA + diag(GEi <- GE[,,i])
      AND <- AND * (GEi + (1-GEi)*(1-t(GEi))) }
    return(as.numeric(AND * ((c(nNA)%o%c(nNA))>0))) }

  tkn <- unlist(strsplit(frml,""))
  nok <- attr(regexpr("[0-9,()]+",frml),"match.length")
  <\dots>
  tmp <- matrix(0, dim(GE)[1]+1, <\dots>)
  FstFree <- function(tmp) match(TRUE, tmp[1,]==0, nomatch=0)

  level <- i <- 0
  while ((i <- i+1) <= nok) {
    switch( tkn[i],
      "(" = level <- level + 1,
      "," = next,
      ")" = { tmp[1, use <- (tmp[1,]==level)] <- 0
              tmp[, FstFree(tmp)] <- c(level <- level-1, mu.AND(tmp[-1, use]))},
      { num <- as.numeric(substring(
               frml,i,i<-i-1+regexpr("[,)]",substring(frml,i+1)))
        <\dots>
        tmp[,FstFree(tmp)] <- c(level, GE[, num]) } ) }
  return(tmp[-1,1])
}

Author(s)

Knut M. Wittkowski kmw@rockefeller.edu, Tingting Song ttsong@gmail.com

Examples

1
2
3
4
5
mu.AND(mu.GE(matrix(1:60, , 3)))
a.1 <- 1:10
a.2 <- 3:12
b <- c(1:5,2:6)
mu.AND(mu.GE(cbind(a.1,a.2,b)), frml="((1,2),3)")

muStat documentation built on May 2, 2019, 5:12 a.m.

Related to F5-mu.AND in muStat...