R/pool_estimates.R

Defines functions pool.estimates

Documented in pool.estimates

# // Pooling of parameter estimates

pool.estimates <- function(model) {

  m <- length(model)

  # extract results
  qhat <- do.call(cbind, lapply(model, coef))
  uhat <- do.call(cbind, lapply(model, function(x) diag(vcov(x))))

  # pool estimates
  qbar <- rowMeans(qhat)
  ubar <- rowMeans(uhat)
  b <- apply(qhat, 1, var)
  v <- b / m + ubar
  se <- sqrt(v)

  r <- (b / ubar) / m
  nu <- (m - 1) * (1 + 1 / r)^2

  t_val <- qbar / se
  p_val <- 2 * pt(abs(t_val), df = nu, lower.tail = FALSE)

  # prepare output
  out <- list(
    estimates = cbind(est = qbar, se = se, df = nu, t_val = t_val, p_val = p_val)
  )

  class(out) <- "robosynth.pooled.estimates"
  return(out)

}
simongrund1/robosynth documentation built on March 20, 2022, 6:15 p.m.