R/tsmvr_predict.R

Defines functions tsmvr_predict

Documented in tsmvr_predict

#' predicts a response from a tsmvr model
#'
#' Given a design matrix \code{X}, predicts a response using the
#' the model found by \code{tsmvr_solve}.
#'
#' @param tsmvr_list output list from tsmvr_solve
#' @param X the design matrix the response is predicted from
#'
#' @note \code{\link{tsmvr}}.
#'
#' @export

tsmvr_predict <- function(tsmvr_list, X) {
  stopifnot(
    is.list(tsmvr_list),
    "B_hat" %in% names(tsmvr_list),
    is.numeric(tsmvr_list$B_hat),
    is.matrix(tsmvr_list$B_hat),
    is.numeric(X),
    is.matrix(X),
    dim(X)[2] == dim(tsmvr_list$B_hat)[1]
  )
  return(X %*% tsmvr_list$B_hat)
}
spcorum/tsmvr documentation built on Aug. 31, 2019, 8:58 p.m.