wtmat: wtmat

Description Usage Arguments Author(s) References Examples

Description

Computes the weight matrix W used in the rank-based GEE fit. See Section 8.6 of Kloke and McKean (2014).

Usage

1
wtmat(dmatb, eitb, med = TRUE, scores = wscores, hbrs = FALSE)

Arguments

dmatb
eitb
med
scores
hbrs

Author(s)

Joseph W. McKean

References

Kloke and McKean (2014), Nonparametrics Using R, Boca Raton: Chapman-Hall.

Examples

 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
32
33
34
35
36
37
38
39
40
41
42
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (dmatb, eitb, med = TRUE, scores = wscores, hbrs = FALSE) 
{
    n <- length(eitb)
    u <- (1:n)/(n + 1)
    eps <- 1e-06
    sc <- getScores(scores, u)
    top <- sc[rank(eitb, ties.method = "first")]
    wts <- rep(0, n)
    if (med) {
        mb <- median(eitb)
        ehat <- eitb - mb
        wts <- top/ehat
        wts[is.infinite(wts)] <- 0
        wts[is.nan(wts)] <- 0
        wts[wts == 0] <- max(wts)
    }
    else {
        scl <- sc[sc < 0]
        mp1 <- length(scl) + 1
        eitbs <- sort(eitb)
        mb <- eitbs[mp1]
        ehat <- eitb - mb
        wts <- top/ehat
        wts[is.infinite(wts)] <- 0
        wts[is.nan(wts)] <- 0
        wts[wts == 0] <- max(wts)
    }
    if (hbrs) {
        wts2 <- hbrwtsnew(dmatb, eitb)
        newwts <- wts * wts2
        newwts[is.infinite(wts)] <- 0
        newwts[is.nan(wts)] <- 0
        newwts[wts == 0] <- max(wts)
        wts <- newwts
    }
    list(wts = wts, mb = mb)
  }

kloke/rbgee documentation built on May 20, 2019, 12:34 p.m.