R/construct_matrix.R

Defines functions construct_interp_survival_matrix

Documented in construct_interp_survival_matrix

#' Constructs survival matrix for use in applied data examples
#'
#' @param x covariates
#' @param nT number of unique times
#' @param intercept include an intercept?
#'
#' @return
#' @export
construct_interp_survival_matrix <- function(x, nT, intercept = FALSE) {

  n <- nrow(x)
  d <- ncol(x)

  xmat <- matrix(0, nrow=n * nT, ncol = d * nT)

  for(t in 1:nT) {
    rows <- seq(1, n * nT, nT) + (t-1)
    cols <- 1:d + (t-1) * d
    xmat[rows, cols] <- x
  }
  if(intercept) xmat <- cbind(1,xmat)
  return(xmat)
}
eifer4/CoarsePosteriorSummary documentation built on April 10, 2021, 12:40 p.m.