R/get_scaled_data.R

Defines functions get_data_scaled

Documented in get_data_scaled

#' @title Scaling data outside \code{plspm}
#' 
#' @details
#' Internal function. \code{get_scaled_data} is called by \code{plspm.groups}
#' and others.
#' 
#' @note 
#' In non-metric case, all mvs are starndardized, and those ordinal or nominal
#' are rankified
#' 
#' @param DM matrix or data frame from with manifest variables
#' @param scaled whether to scale latent variables
#' @return matrix or data frame of (un)scaled MVs 
#' @keywords internal
#' @template internals
#' @export
get_data_scaled <- function(DM, scaled) {
  if (scaled) {
    sd.X <- sqrt((nrow(DM)-1)/nrow(DM)) * apply(DM, 2, sd)
    X <- scale(DM, scale=sd.X)
  } else {
    X <- scale(DM, scale=FALSE)
  }
  # output
  X
}

Try the plspm package in your browser

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

plspm documentation built on March 31, 2023, 11:54 p.m.