veear1m: veear1m

Description Usage Arguments Author(s) References Examples

Description

Computes AR(1) estimate for workink covariance matrix. Structure should be set at "AR". See Section 8.6.3 of Kloke and McKean (2014).

Usage

1
veear1m(ehat, center, scores)

Arguments

ehat
center
scores

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
##---- 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, center, scores) 
{
    numc <- max(center)
    n <- length(ehat)
    rho <- rep(0, numc)
    sig <- rep(0, numc)
    for (i in 1:numc) {
        ehatc <- ehat[center == i]
        ni <- length(ehatc)
        elp1 <- ehatc[2:ni]
        elm1 <- ehatc[1:(ni - 1)]
        fiti <- rfit(elp1 ~ elm1, scores = scores)
        rho[i] <- fiti$coef[2]
        sig[i] <- mad(fiti$resid)
    }
    rhomed <- median(rho)
    sigmed2 <- median(sig)^2
    if (rhomed > 0.95) {
        rhomed <- 0.95
    }
    if (rhomed < -0.95) {
        rhomed <- -0.95
    }
    vc <- c(sigmed2, rhomed)
    return(vc)
  }

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