princals: Categorical principal component analysis (PRINCALS).

princalsR Documentation

Categorical principal component analysis (PRINCALS).

Description

Fits a categorical PCA. The default is to take each input variable as ordinal but it works for mixed scale levels (incl. nominal) as well. Through a proper spline specification various continuous transformation functions can be specified: linear, polynomials, and (monotone) splines.

Usage

princals(data, ndim = 2, levels = "ordinal", ordinal, knots, ties = "s", 
degrees = 1, copies = 1, missing = "s", normobj.z = TRUE, active = TRUE,
itmax = 1000, eps = 1e-06, verbose = FALSE)

Arguments

data

Input data frame: n observations, m variables

ndim

Number of dimensions to be computed

levels

A vector of length m denoting basic scale levels ("nominal", "ordinal", "metric"; see details

ordinal

If knots are specified manually, a boolean vector of length m denotes which variables should be ordinally restricted or not (see details)

knots

Scale levels can be specified manually using splines (see knotsGifi). If knots is set, this overrides level (see details)

ties

How ties should be handled: primary ("p"), secondary ("s"), or tertiary ("t")

degrees

Spline degrees. If different degrees should be used across variables, a vector of length m can be specified.

copies

Number of copies for each variables (also as vector of length m)

missing

How missing values should be handled: multiple ("m"), single ("s"), or average ("a")

active

Which variables should be active or inactive (also as vector of length m)

normobj.z

If TRUE, object scores are z-scores, if FALSE, they are restriction to SS of 1.

itmax

Maximum number of iterations

eps

Convergence criterion

verbose

Iteration printout

Details

The measurement (or scale) levels of the variables are incorporated via spline transformations. If the user only needs simple scale levels like nominal, ordinal, and metric, a corresponding vector can be specified in the levels argument without setting knots and ordinal. The corresponding spline transformations (unrestricted, monotone, and linear) are then created internally. If all scale level transformations are the same, ordinal can be a single value. For more advanced transformations such as polynomial or more flexible splines, the knots and ordinal arguments need to be specified instead of levels.

Value

transform

Optimally transformed scores

rhat

Induced correlation matrix

evals

Eigenvalues of induced correlation matrix

objectscores

Object scores (rows)

scoremat

Optimally scaled data matrix (first dimension)

quantifications

Category quantifications

dmeasures

Discimination matrices

lambda

Average discrimination matrix

weights

Component weights

loadings

Component loadings

ntel

Number of iterations

f

Loss function value

data

Original data frame

datanum

Numerical data frame

ndim

Number of extracted dimensions

call

Function call

References

Gifi, A. (1990). Nonlinear Multivariate Analysis. New York: Wiley.

De Leeuw, J., Mair, P., Groenen, P. J. F. (2017). Multivariate Analysis with Optimal Scaling.

See Also

homals, plot.princals

Examples

ABC6 <- ABC[,6:11]

## ordinal PCA
fitord <- princals(ABC6)  ## ordinal PCA
fitord
summary(fitord)

plot(fitord, plot.type = "transplot")
plot(fitord, "loadplot", main = "Loadings Plot ABC Data")  ## aspect ratio = 1
plot(fitord, "biplot", main = "Biplot ABC Data")
plot(fitord, "screeplot")

## linear restrictions (mimics standard PCA)
abc_knots <- knotsGifi(ABC6, "E")     ## 0 interior knots
fitlin <- princals(ABC6, knots = abc_knots, ordinal = TRUE)  
fitlin 
fitlin$evals
plot(fitlin, plot.type = "transplot")

## compare with standard PCA
ABCnum <- makeNumeric(ABC6)
fitpca <- prcomp(ABCnum, scale = TRUE)
fitpca$sdev^2   

## more complicated specifications
## Not run: 
data(epi.bfi, package = "psychTools")
epi6 <- epi.bfi[,1:6]
fitepi1 <- princals(epi6, knots = knotsGifi(epi6, "Q"))    ## monotone splines (degree 2)
fitepi1
plot(fitepi1, "transplot")

## no interior knots vars 1 and 2; data knots vars 3 and 4; 5 
## interior percentile knots var 5; no interior knots var 6)
knotList <- c(knotsGifi(epi6[,1:2], "E"), 
              knotsGifi(epi6[,3:4], "D"), 
              knotsGifi(epi6[,5], "Q", n = 5),
              knotsGifi(epi6[,6], "E"))
knotList  
ordvec <- c(TRUE, FALSE, TRUE, FALSE, FALSE, TRUE) ## ordinal restrictions
degvec <- c(3, -1, 2, 2, 3, 1)                     ## spline degrees (second variable nominal)
fitepi2 <- princals(epi6, knots = knotList, ordinal = ordvec, degrees = degvec)
fitepi2
plot(fitepi2, "transplot")

## End(Not run)


Gifi documentation built on Sept. 28, 2022, 3 a.m.

Related to princals in Gifi...