R/build_mean_mat.R

Defines functions build_mean_mat

#' Internal function to generate a matrix of coefficients that will be multiplied to the reference mean to generate an experimental model.
#'
#'
#'
#' @noRd

build_mean_mat <- function(fAvec, fBvec, iA, a, b, label_list = label_list, bystart=TRUE)
{
    if(all(diff(diff(fAvec))<1e-4) | !bystart)
    {
      Bdelta <- diff(fAvec)[1]
    }
    if(iA!=1)
    {
      Bincrements <- seq(0, Bdelta*(a-1), Bdelta)
      mmat <- outer(Bincrements, fBvec, FUN = "+")
    }
    else if (iA==1 & bystart)
    {
      mmat <- rep(fBvec, a)
      mmat <- matrix(mmat, a, b, byrow = TRUE)
    } else if (iA==1 & !bystart)
    {
      mmat <- rep(fBvec, each=a)
      mmat <- matrix(mmat, a, b)
    }
  dimnames(mmat) <- label_list
  mmat
}

Try the extraSuperpower package in your browser

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

extraSuperpower documentation built on Aug. 8, 2025, 6:44 p.m.