R/factor_scores.R

Defines functions factor_scores factor_scores.mcfa factor_scores.mctfa factor_scores.mfa factor_scores.mtfa

Documented in factor_scores factor_scores.mcfa factor_scores.mctfa

factor_scores <- function(model, Y, ...) UseMethod("factor_scores")

factor_scores.mcfa <- function(model, Y, tau = NULL, clust= NULL, ...) {
  
  if (any(class(Y) %in% "data.frame")) {
    Y <- as.matrix(Y)
  }
  
if (!any(class(Y) %in% "matrix"))
    stop("Y needs to be a numeric matrix")
  
  if ((!is.null(tau)) || (exists ("tau"))) {
    model$tau <- tau
  }
  
  if ((!is.null(clust)) || (exists ("clust"))) {
    model$clust <- clust
  }
  
  scores <- do.call("factor_scores_mcfa", c(list(Y = Y), model))
  scores
}

factor_scores.mctfa <- function(model, Y, tau = NULL, clust= NULL, ...) {
  
  if (any(class(Y) %in% "data.frame")) {
    Y <- as.matrix(Y)
  }
  
  if (!any(class(Y) %in% "matrix"))
    stop("Y needs to be a numeric matrix")
  
  if ((!is.null(tau)) || (exists ("tau"))) {
    model$tau <- tau
  }
  
  if ((!is.null(clust)) || (exists ("clust"))) {
    model$clust <- clust
  }
  
  scores <- do.call("factor_scores_mctfa", c(list(Y = Y), model))
  scores
}

factor_scores.mfa <- function(model, Y, tau = NULL, clust= NULL, ...) {
  
  if (any(class(Y) %in% "data.frame")) {
    Y <- as.matrix(Y)
  }
  
  if (!any(class(Y) %in% "matrix"))
    stop("Y needs to be a numeric matrix")
  
  if ((!is.null(tau)) || (exists ("tau"))) {
    model$tau <- tau
  }
  
  if ((!is.null(clust)) || (exists ("clust"))) {
    model$clust <- clust
  }
  
  scores <- do.call("factor_scores_mfa", c(list(Y = Y), model))
  scores
}

factor_scores.mtfa <- function(model, Y, tau = NULL, clust= NULL, ...) {
  
  if (any(class(Y) %in% "data.frame")) {
    Y <- as.matrix(Y)
  }
  
  if (!any(class(Y) %in% "matrix"))
    stop("Y needs to be a numeric matrix")
  
  if ((!is.null(tau)) || (exists ("tau"))) {
    model$tau <- tau
  }
  
  if ((!is.null(clust)) || (exists ("clust"))) {
    model$clust <- clust
  }
  
  scores <- do.call("factor_scores_mtfa", c(list(Y = Y), model))
  scores
}

Try the EMMIXmfa package in your browser

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

EMMIXmfa documentation built on Dec. 18, 2019, 1:40 a.m.