methods-mca | R Documentation |
These methods extract data from, and attribute new data to,
objects of class "mca"
from the MASS package.
## S3 method for class 'mca' as_tbl_ord(x) ## S3 method for class 'mca' recover_rows(x) ## S3 method for class 'mca' recover_cols(x) ## S3 method for class 'mca' recover_inertia(x) ## S3 method for class 'mca' recover_conference(x) ## S3 method for class 'mca' recover_coord(x) ## S3 method for class 'mca' recover_supp_rows(x) ## S3 method for class 'mca' recover_aug_rows(x) ## S3 method for class 'mca' recover_aug_cols(x) ## S3 method for class 'mca' recover_aug_coord(x)
x |
An ordination object. |
Multiple correspondence analysis (MCA) relies on a singular value
decomposition of the indicator matrix X of a table of several
categorical variables, scaled by its column totals. MASS::mca()
returns the
SVD factors UD and V as the row weights $fs
, on which the
inertia is conferred, and the column coordinates $cs
. The row coordinates
$rs
are obtained as XV and accessible as supplementary elements.
The recovery generics recover_*()
return core model components, distribution of inertia,
supplementary elements, and intrinsic metadata; but they require methods for each model class to
tell them what these components are.
The generic as_tbl_ord()
returns its input wrapped in the 'tbl_ord'
class. Its methods determine what model classes it is allowed to wrap. It
then provides 'tbl_ord' methods with access to the recoverers and hence to
the model components.
Other methods for singular value decomposition-based techniques:
methods-cancor
,
methods-correspondence
,
methods-lda
,
methods-lra
,
methods-prcomp
,
methods-princomp
,
methods-svd
Other models from the MASS package:
methods-correspondence
,
methods-lda
# table of admissions and rejections from UC Berkeley class(UCBAdmissions) ucb_admissions <- as.data.frame(UCBAdmissions) ucb_admissions <- ucb_admissions[rep(seq(nrow(ucb_admissions)), ucb_admissions$Freq), -4L] head(ucb_admissions) # perform multiple correspondence analysis ucb_admissions %>% MASS::mca() %>% as_tbl_ord() %>% # augment profiles with names, masses, distances, and inertias augment_ord() %>% print() -> admissions_mca # recover row and column coordinates and row weights head(get_rows(admissions_mca, elements = "score")) get_cols(admissions_mca) head(get_rows(admissions_mca)) # column-standard biplot of factor levels admissions_mca %>% ggbiplot() + theme_bw() + theme_biplot() + geom_origin() + #geom_rows_point(stat = "unique") + geom_cols_point(aes(color = factor, shape = factor)) + geom_cols_text_repel(aes(label = level, color = factor), show.legend = FALSE) + scale_color_brewer(palette = "Dark2") + scale_size_area(guide = "none") + labs(color = "Factor level", shape = "Factor level")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.