dudi.pca {ade4} | R Documentation |
dudi.pca
performs a principal component analysis of a data frame and
returns the results as objects of class pca
and dudi
.
dudi.pca(df, row.w = rep(1, nrow(df))/nrow(df), col.w = rep(1, ncol(df)), center = TRUE, scale = TRUE, scannf = TRUE, nf = 2)
df |
a data frame with n rows (individuals) and p columns (numeric variables) |
row.w |
an optional row weights (by default, uniform row weights) |
col.w |
an optional column weights (by default, unit column weights) |
center |
a logical or numeric value, centring option if TRUE, centring by the mean if FALSE no centring if a numeric vector, its length must be equal to the number of columns of the data frame df and gives the decentring |
scale |
a logical value indicating whether the column vectors should be normed for the row.w weighting |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
Returns a list of classes pca
and dudi
(see dudi) containing also :
cent |
a vector with p components |
norm |
a vector with p components |
if x[i,j] is the value of the table df and y[i,j] is the value of the table $tab
, we have:
y[i,j] = (x[i,j] - cent[j]) / norm[j]
x[i,j] = y[i,j]*norm[j] + cent[j]
Daniel Chessel chessel@biomserv.univ-lyon1.fr
Anne B Dufour dufour@biomserv.univ-lyon1.fr
prcomp
, princomp
in the mva
library
data(deug) deug.dudi <- dudi.pca(deug$tab, center = deug$cent, scale = FALSE, scan = FALSE) par(mfrow = c(2,2)) s.class(deug.dudi$li, deug$result, cpoint = 1) s.arrow(deug.dudi$c1, lab = names(deug$tab)) deug.dudi1 <- dudi.pca(deug$tab, center = TRUE, scale = TRUE, scan = FALSE) s.class(deug.dudi1$li, deug$result, cpoint = 1) s.corcircle(deug.dudi1$co, lab = names(deug$tab), full = FALSE, box = TRUE) par(mfrow = c(1,1)) # for interpretations par(mfrow = c(3,3)) par(mar = c(2.1,2.1,2.1,1.1)) for(i in 1:9) { hist(deug.dudi$tab[,i], xlim = c(-40,40), breaks = seq(-45, 35, by = 5), prob = TRUE, right = FALSE, main = names(deug$tab)[i], xlab = "", ylim = c(0,0.10)) abline(v = 0, lwd = 3) } par(mfrow = c(1,1))