R/RunLMode.R

Defines functions RunLMode

Documented in RunLMode

RunLMode <-
function(x) {
  # 
  # Performs L-Mode analysis.
  #
  # Args:
  #   x: Data (matrix).
  #
  # Returns:
  #   LMode curve (factor score density; list, vectors of x and y values).
  # 
  n <- dim(x)[1]
  factoring <- RunFactorAnalysis(x, n.factors = 1)
  scores <- apply(x %*% factoring$loadings %*% solve(t(factoring$loadings) %*% 
    factoring$loadings), 2, scale)
  density.score <- density(scores)
  curve.x <- density.score$x
  curve.y <- density.score$y
  return(list(curve.x = curve.x, curve.y = curve.y))
}

Try the RTaxometrics package in your browser

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

RTaxometrics documentation built on May 31, 2023, 8:29 p.m.