R/totalEffects.R

Defines functions totalEffects totalEffects.default totalEffects.sempls print.totalEffects

Documented in print.totalEffects totalEffects totalEffects.sempls

totalEffects <- function(object){
  UseMethod("totalEffects", object)
}

# Calculates the total effects
totalEffects.default <- function(pathCoeff){
  ret <- pathCoeff
  step <- pathCoeff
  for (i in 2:ncol(pathCoeff)){
    step <- step %*% pathCoeff
    ret <- step + ret
  }
  return(ret)
}

totalEffects.sempls <- function(object){
  coeffs <- object$total_effects
  class(coeffs) <- "totalEffects"
  return(coeffs)
}

print.totalEffects <- function(x, na.print=".", digits=2, abbreviate=FALSE, ...){
  coeffs <- x
  coeffs[coeffs==0] <- NA
  if(abbreviate) dimnames(coeffs) <- lapply(dimnames(coeffs), abbreviate, ...)
  print.table(coeffs, na.print=na.print, digits=digits, ...)
  invisible(x)
}

Try the semPLS package in your browser

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

semPLS documentation built on May 2, 2019, 9:34 a.m.