R/hero.prepared_matrix.R

Defines functions hero.prepared_matrix

Documented in hero.prepared_matrix

#' @rdname hero
#' @export
hero.prepared_matrix = function(x, ...) {
  lambda = exp(x$loglambda)
  parts = lapply(seq_along(lambda), function(i) {
    x$Q[[i]] %*% x$U[[i]] %*% diag(1/(1 + lambda[i]*x$s[[i]]))
  })
  coeffs = rh.seq(parts, x$Ytilde)
  fitted = as.matrix(x$B[[1]] %*% Matrix::tcrossprod(coeffs, x$B[[2]]))
  out = list(fitted = fitted, coefficients = coeffs, x = x$x,
             sts = x$sts)
  class(out) = c("hero_matrix", "hero")
  return(out)
}

Try the hero package in your browser

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

hero documentation built on July 26, 2023, 5:11 p.m.