R/step6.R

Defines functions estimatePLS_Step6

estimatePLS_Step6 <- function(model) {
  model$factorScores <- getFactorScores(model)

  if (model$info$is.nlin) {
    # Update variance and coefficients of interaction terms
    elems <- model$info$intTermElems
    names <- names(elems)
    X     <- model$factorScores

    SC <- model$matrices$SC
    C  <- model$matrices$C
    L  <- model$matrices$lambda
    G  <- model$matrices$gamma

    for (elems.xz in elems) {
      xz <- paste0(elems.xz, collapse = ":")
      X[,xz] <- Rfast::rowprods(X[,elems.xz])
    }

    Cxz <- Rfast::cova(X)
    par <- colnames(X)

    model$factorScores <- X
    model$matrices$C[par, par] <- Cxz
    model$matrices$SC[par, par] <- Cxz
  }

  model
}

Try the plssem package in your browser

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

plssem documentation built on March 23, 2026, 5:08 p.m.