varest: Estimates of the covariance.

Description Usage Arguments Details Value Author(s) References Examples

Description

Estimates of the variance covariance of the scores. Used in estimating variance covariance of the linear model estimates and also in the score test.

Usage

1
tcs(ehat, X, block, ahat = NULL, scores = wscores, eps = 1e-04)

Arguments

ehat

N x 1 vector of residuals

X

N x p design matrix

block

N x 1 vector denoting block membership

ahat

optional vector of scores evaluated at the residual (if null then is computed using ehat and scores)

scores

score function used in the fit of ehat

eps

used in tcs to ensure positive definite

Details

Estimates vhat = sum_k^m X_k^T varphi_k X_k. See Kloke, McKean, Rashid (2009) for details.

Value

p x p matrix

Author(s)

John Kloke <kloke@biostat.wisc.edu>

References

Kloke, J.D., McKean, J.W., Rashid, M. (2009), Rank-based estimation and associat ed inferences for linear models with cluster correlated errors, Journal of the American Statistical Association, 104, 384-390.

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
##---- 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 (ehat, X, block, ahat = NULL, scores = wscores, eps = 1e-04) 
{
    if (is.null(ahat)) 
        ahat <- getScores(scores, ehat)
    nvec <- tapply(ehat, block, length)
    M <- sum(choose(nvec, 2)) - ncol(X)
    myfunc <- function(ak) {
        Ak <- tcrossprod(ak)
        Ak[upper.tri(Ak)]
    }
    rhohat <- sum(unlist(tapply(ahat, block, myfunc)))/M
    K0 <- -1/(max(nvec) - 1)
    if (rhohat < K0) 
        rhohat <- K0 + eps
    if (rhohat > 1) 
        rhohat <- 1 - eps
    myfunc <- function(i, x, rhohat) {
        xi <- as.matrix(x[i, ])
        ni <- nrow(xi)
        sk <- matrix(rhohat, nrow = ni, ncol = ni)
        diag(sk) <- 1
        t(xi) %*% sk %*% xi
    }
    Reduce("+", tapply(1:nrow(X), block, myfunc, X, rhohat))
  }

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