R/Predict.matrix.cb.smooth.R

Defines functions Predict.matrix.cb.smooth

Documented in Predict.matrix.cb.smooth

###
### R routines for the R package dlnm (c)
#
Predict.matrix.cb.smooth <- function(object, data) {
#
################################################################################
#
  # TERMS AND DIMENSIONS
  term <- object$term
  dim <- length(term)
#
  # BUILD MARGINAL BASES
  Xm <- list()
  for (i in seq(dim)) { 
    margin <- object$margin[[i]]
    if(!"onebasis"%in%class(margin)) {
      Xm[[i]] <- if(object$mc[i]) PredictMat(margin,data,n=length(data[[1]])) else 
        Predict.matrix(margin,data)
    } else {
      Xm[[i]] <- do.call("onebasis",c(list(x=data[[term[i]]]),margin))
    }
  }
#
  # NB: NO REPARAMETERIZATION THROUGH XP
  # TENSOR (USING mgcv FUNCTION)
  X <- tensor.prod.model.matrix(Xm)
#
  return(X)
}

Try the dlnm package in your browser

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

dlnm documentation built on Oct. 7, 2021, 5:09 p.m.