R: u-Scores and Weights

mu.Sums {muStat} | R Documentation

## u-Scores and Weights

### Description

mu.Sums computes u-scores and weights from a partial ordering.

### Usage

    mu.Sums(GE, dsgn=1, wght=TRUE)
    mu.wScr  (x, y=NULL, frml=NULL, dsgn=1, wght=TRUE)
    mu.score (x, y=NULL, frml=NULL, dsgn=1, wght=FALSE)
    mu.weight(x, y=NULL, frml=NULL, dsgn=1, wght=TRUE)

### Arguments

`GE` | partial ordering
`x` | data matrix, variables as columns
`y` | data matrix, variables as columns
`frml` | see `mu.AND`,
`dsgn` | design of the experiment.
`wght` | logical flag, if weights should be calculated.

### Value

`score` | u-scores
`weight` | weights
`nBelow` | number of observations that are inferior
`nAbove` | number of observations that are superior
`nEqual` | number of observations that are equivalent

### Algorithm

    mu.Sums <- function(GE, dsgn=1, wght=TRUE) {
        ICW <- function(GE,dsgn) {
            wgt <- colSums(GE|t(GE))        # 0: orig NA, 1: like NA, >1: no NA
            sqrt(wgt*(wgt>1)/if (dsgn!=1) colSums(dsgn) else nrow(GE))
        }
        GE <- sq.matrix(GE)
        nE <- colSums(GE*t(GE))
        nA <- colSums(GE) - nE
        nB <- rowSums(GE) - nE
    	weight <- ifelse1(wght, ICW(GE,dsgn), rep(1, length(nE)))
    	list(score  = (nB-nA) * ifelse(weight==0,NA,1),
    		weight = weight,
    		nBelow = nB,
    		nAbove = nA,
    		nEqual = nE)
    }

    mu.wScr <- function(x, y=NULL, frml=NULL, dsgn=1, wght=TRUE)
    	mu.Sums(mu.AND(mu.GE(x, y), frml), dsgn=dsgn, wght=wght)

    mu.score  <- function(x, y=NULL, frml=NULL, dsgn=1, wght=FALSE)
    	mu.Sums(mu.AND(mu.GE(x, y), frml), dsgn=dsgn, wght=wght)$score

    mu.weight <- function(x, y=NULL, frml=NULL, dsgn=1, wght=TRUE)
    	mu.Sums(mu.AND(mu.GE(x, y), frml), dsgn=dsgn, wght=wght)$weight

### Author(s)

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

### Examples

    mu.Sums(mu.GE(1:100))
    a.1 <- 1:10
    a.2 <- 3:12
    b <- c(1:5,2:6)
    mu.wScr(cbind(a.1,a.2,b), frml="((1,2),3)")

[Package muStat version 1.7.0 Index]