PrincipalComponentsAnalysis: 'PrincipalComponentsAnalysis'

View source: R/principalcomponentsanalysis.R

PrincipalComponentsAnalysisR Documentation

PrincipalComponentsAnalysis

Description

Calculate a Principal Component Analysis

Usage

PrincipalComponentsAnalysis(
  data,
  weights = NULL,
  subset = NULL,
  missing = "Exclude cases with missing data",
  use.correlation = TRUE,
  rotation = "none",
  oblimin.delta = 0,
  promax.kappa = 4,
  select.n.rule = "Number of factors",
  eigen.min = 1,
  n.factors = 2,
  sort.coefficients.by.size = FALSE,
  suppress.small.coefficients = FALSE,
  min.display.loading.value = 0.1,
  print.type = "loadings",
  show.labels = TRUE,
  plot.labels = TRUE,
  data.groups = NULL,
  tol = 1e-13,
  use.combined.scatter = FALSE
)

## S3 method for class 'flipFactorAnalysis'
fitted(object, ...)

Arguments

data

A data frame with numeric columns which contains the data to be analyzed.

weights

A numeric vector containing the weight for each case in data.

subset

A logical vector which describes the subset of data to be analyzed.

missing

A string specifiying what to do when the data contains missing values. The valid options are "Error if missing data", "Exclude cases with missing data", "Use partial data (pairwise correlations)", and "Imputation (replace missing values with estimates)".

use.correlation

A logical value specifying whether to use the correlation matrix (TRUE), or the covariance matrix (FALSE).

rotation

A string specifying the type of rotation to be used. Valid options are "none", "varimax", "quartimax", "equamax", "promax", and "oblimin".

oblimin.delta

A parameter supplied for oblimin rotations.

promax.kappa

A parameter supplied for promax rotations.

select.n.rule

Method for selecting the number of principal components to keep. May be one of "Kaiser rule", "Eigenvalues over", or "Number of components".

eigen.min

Cut-off above which eigenvalues are selected. Used if select.n.rule is "Eigenvalues over".

n.factors

An integer specifying the number of principal components to keep. Used if select.n.rule is "Number of components".

sort.coefficients.by.size

A logical value determining whether loadings should be sorted when printed.

suppress.small.coefficients

A logical value specifying whether components that are less than min.display.loading.value in magnitude will be replaced with blanks when printing.

min.display.loading.value

Loadings smaller than this value will not be displayed when printed.

print.type

A string specifying the type of printing that should be done. Valid options are "loadings" to display a (rotated) loading table, "structure" to display a component structure matrix (which is the loadings multiplied by the component correlations), "details" to display a plain-text output containing more details from the analysis, "variance" to display a table showing the original eigenvalues of the input, and the corresponding variance explained, "scree" to display a Scree Plot, "scatter" to display a plot of the first two dimensions of the final loadings, and "2d" to plot the first two dimensions of the data, grouped by a categorical variable. The latter three options make use of HTML widgets.

show.labels

If TRUE, labels are shown rather than name in outputs.

plot.labels

A logical value which determines whether or not the scatter plot will show the labels of the input data, or just integers specifying the column number of each variable.

data.groups

A vector of labels used to group the cases when "print.type" is "2d".

tol

When the correlation martrix (or covariance) matrix has any singular values below this number the analysis will stop. Note that the function principal from package psych has its own internal cuttoff as well.

object

Object of class "flipFactorAnalysis" created using PrincipalComponentsAnalysis.

use.combined.scatter

Draw scatterplots using rhtmlCombinedScatter.

...

Not used.

Details

This uses principal from package psych to compute the unrotated PCA, and uses package GPArotation to find a rotated solution if required, to match SPSS' PCA. The rotation includes a Kaiser normalization and a method of Promax which matches what SPSS does. Components with large negative loadings will have signs flipped to give positive components after rotation. Includes handling of missing data, weighting, and filtering.


Displayr/flipDimensionReduction documentation built on Aug. 19, 2024, 9:29 p.m.