R/covSIR.R

Defines functions covSIR

Documented in covSIR

covSIR <- function(X, y, h = 10, ...) {
  n <- nrow(X)
  slices <- as.matrix(cut(y, breaks = c(quantile(y, probs = seq(0, 1, by = 1/h), ...)),
                          include.lowest = TRUE ,labels = FALSE))
  slicemean <- do.call(rbind, by(X, slices, colMeans))
  nh <- as.numeric(table(slices))
  cov.wt(slicemean, wt=nh/n, method="ML")$cov
  #cov(slicemean)
}

Try the ICtest package in your browser

Any scripts or data that you put into this service are public.

ICtest documentation built on May 18, 2022, 9:05 a.m.