mrgrad: Gradiant of the MR dispersion function.

Description Usage Arguments Value Author(s) References Examples

Description

Gradiant, with respect to beta, of the MR dispersion function. Used in minimization routine.

Usage

1
mrgrad(x, y, center, beta)

Arguments

x

n by p design matrix

y

n by 1 response vector

center

n by 1 vector denoting block (cluster) membership

beta

p by 1 vector

Value

Gradient of MR dispersion function evaluated at beta.

Author(s)

John Kloke kloke@biostat.wisc.edu

References

Rashid, M.M., McKean, J.W., Kloke, J.D. (2011). R Estimates and Associated Inferences for Mixed Models with Covariates in a Multi-Center Clinical Trial. Statistics in Biopharmaceutical Research.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
### Internal function ###

## The function is currently defined as
function (x, y, center, beta) 
{
    p <- ncol(x)
    a <- unique(center)
    nc <- length(a)
    Smat <- matrix(nrow = p, ncol = nc)
    Dvec <- rep(0, nc)
    beta <- as.matrix(beta)
    for (j in 1:nc) {
        x1 <- as.matrix(x[center == a[j], ])
        y1 <- y[center == a[j]]
        nj <- length(y1)
        e <- y1 - x1 %*% beta
        sj <- as.matrix(sqrt(12) * (rank(e, ties.method = "random")/(nj + 
            1) - 0.5))
        Smat[, j] <- t(x1) %*% sj
    }
    apply(Smat, 1, sum)
  }

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