These methods extract data from, and attribute new data to,
objects of class "eigen"
returned by base::eigen()
when the parameter
only.values
is set to FALSE
or of class "eigen_ord"
returned by
eigen_ord()
.
# S3 method for eigen
as_tbl_ord(x)
# S3 method for eigen
recover_rows(x)
# S3 method for eigen
recover_cols(x)
# S3 method for eigen
recover_inertia(x)
# S3 method for eigen
recover_coord(x)
# S3 method for eigen
recover_conference(x)
# S3 method for eigen_ord
recover_aug_rows(x)
# S3 method for eigen_ord
recover_aug_cols(x)
# S3 method for eigen
recover_aug_coord(x)
# S3 method for eigen_ord
as_tbl_ord(x)
# S3 method for eigen_ord
recover_rows(x)
# S3 method for eigen_ord
recover_cols(x)
# S3 method for eigen_ord
recover_inertia(x)
# S3 method for eigen_ord
recover_coord(x)
# S3 method for eigen_ord
recover_conference(x)
# S3 method for eigen_ord
recover_aug_rows(x)
# S3 method for eigen_ord
recover_aug_cols(x)
# S3 method for eigen_ord
recover_aug_coord(x)
An ordination object.
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.
base::eigen()
usually returns an object of class "eigen"
, which contains
the numerical eigendecomposition without annotations such as row and column
names. To facilitate downstream analysis, eigen_ord()
returns a modified
'eigen' object with row names taken (if available) from the original data and
column names indicating the integer index of each eigenvector.
Other methods for eigen-decomposition-based techniques:
methods-cmds
,
methods-factanal
Other models from the base package:
methods-svd
# subset QS data to rank variables
qs_ranks <- subset(
qswur_usa,
complete.cases(qswur_usa),
select = 8:13
)
head(qs_ranks)
#> # A tibble: 6 × 6
#> rk_academic rk_employer rk_ratio rk_citations rk_intl_faculty rk_intl_students
#> <int> <int> <int> <int> <int> <int>
#> 1 6 4 12 10 33 65
#> 2 5 5 20 14 52 170
#> 3 1 1 42 8 47 184
#> 4 23 90 3 4 136 112
#> 5 13 47 54 49 232 182
#> 6 10 32 115 3 239 192
# eigendecomposition of Kendall correlation matrix
qs_ranks %>%
cor(method = "kendall") %>%
eigen() %>%
print() -> qs_eigen
#> eigen() decomposition
#> $values
#> [1] 2.9359358 0.8413683 0.8118814 0.6961366 0.5015260 0.2131520
#>
#> $vectors
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] -0.4876816 -0.28115567 0.3779721 0.08143094 -0.05527027 0.728402026
#> [2,] -0.4726835 -0.28941567 0.4021804 0.18473911 -0.20861096 -0.673359308
#> [3,] -0.3114638 0.79289902 0.3704858 -0.18660208 0.31580188 -0.049904822
#> [4,] -0.4119484 -0.29472593 -0.4217199 -0.13454306 0.73312495 -0.100067282
#> [5,] -0.3896137 0.07836083 -0.3770419 -0.65199069 -0.52421836 -0.001847863
#> [6,] -0.3467377 0.33984910 -0.4879754 0.69370486 -0.20351597 0.059248322
#>
# recover eigenvectors
get_rows(qs_eigen)
#> EV1 EV2 EV3 EV4 EV5 EV6
#> [1,] -0.4876816 -0.28115567 0.3779721 0.08143094 -0.05527027 0.728402026
#> [2,] -0.4726835 -0.28941567 0.4021804 0.18473911 -0.20861096 -0.673359308
#> [3,] -0.3114638 0.79289902 0.3704858 -0.18660208 0.31580188 -0.049904822
#> [4,] -0.4119484 -0.29472593 -0.4217199 -0.13454306 0.73312495 -0.100067282
#> [5,] -0.3896137 0.07836083 -0.3770419 -0.65199069 -0.52421836 -0.001847863
#> [6,] -0.3467377 0.33984910 -0.4879754 0.69370486 -0.20351597 0.059248322
identical(get_cols(qs_eigen), get_rows(qs_eigen))
#> [1] TRUE
# wrap as a 'tbl_ord'
as_tbl_ord(qs_eigen)
#> # A tbl_ord of class 'eigen': (6 x 6) x (6 x 6)'
#> # 6 coordinates: EV1, EV2, ..., EV6
#> #
#> # Rows (standard): [ 6 x 6 | 0 ]
#> EV1 EV2 EV3 ... |
#> |
#> 1 -0.488 -0.281 0.378 |
#> 2 -0.473 -0.289 0.402 |
#> 3 -0.311 0.793 0.370 ... |
#> 4 -0.412 -0.295 -0.422 |
#> 5 -0.390 0.0784 -0.377 |
#> 6 -0.347 0.340 -0.488 |
#> #
#> # Columns (standard): [ 6 x 6 | 0 ]
#> EV1 EV2 EV3 ... |
#> |
#> 1 -0.488 -0.281 0.378 |
#> 2 -0.473 -0.289 0.402 |
#> 3 -0.311 0.793 0.370 ... |
#> 4 -0.412 -0.295 -0.422 |
#> 5 -0.390 0.0784 -0.377 |
#> 6 -0.347 0.340 -0.488 |
# same eigendecomposition, preserving row names and adding column names
qs_ranks %>%
cor(method = "kendall") %>%
eigen_ord() %>%
print() -> qs_eigen
#> eigen() decomposition
#> $values
#> [1] 2.9359358 0.8413683 0.8118814 0.6961366 0.5015260 0.2131520
#>
#> $vectors
#> EV1 EV2 EV3 EV4 EV5
#> rk_academic -0.4876816 -0.28115567 0.3779721 0.08143094 -0.05527027
#> rk_employer -0.4726835 -0.28941567 0.4021804 0.18473911 -0.20861096
#> rk_ratio -0.3114638 0.79289902 0.3704858 -0.18660208 0.31580188
#> rk_citations -0.4119484 -0.29472593 -0.4217199 -0.13454306 0.73312495
#> rk_intl_faculty -0.3896137 0.07836083 -0.3770419 -0.65199069 -0.52421836
#> rk_intl_students -0.3467377 0.33984910 -0.4879754 0.69370486 -0.20351597
#> EV6
#> rk_academic 0.728402026
#> rk_employer -0.673359308
#> rk_ratio -0.049904822
#> rk_citations -0.100067282
#> rk_intl_faculty -0.001847863
#> rk_intl_students 0.059248322
#>
# wrap as a 'tbl_ord' and augment with dimension names
augment_ord(as_tbl_ord(qs_eigen))
#> # A tbl_ord of class 'eigen_ord': (6 x 6) x (6 x 6)'
#> # 6 coordinates: EV1, EV2, ..., EV6
#> #
#> # Rows (standard): [ 6 x 6 | 1 ]
#> EV1 EV2 EV3 ... | name
#> | <chr>
#> 1 -0.488 -0.281 0.378 | 1 rk_academic
#> 2 -0.473 -0.289 0.402 | 2 rk_employer
#> 3 -0.311 0.793 0.370 ... | 3 rk_ratio
#> 4 -0.412 -0.295 -0.422 | 4 rk_citations
#> 5 -0.390 0.0784 -0.377 | 5 rk_intl_faculty
#> 6 -0.347 0.340 -0.488 | 6 rk_intl_students
#> #
#> # Columns (standard): [ 6 x 6 | 1 ]
#> EV1 EV2 EV3 ... | name
#> | <chr>
#> 1 -0.488 -0.281 0.378 | 1 rk_academic
#> 2 -0.473 -0.289 0.402 | 2 rk_employer
#> 3 -0.311 0.793 0.370 ... | 3 rk_ratio
#> 4 -0.412 -0.295 -0.422 | 4 rk_citations
#> 5 -0.390 0.0784 -0.377 | 5 rk_intl_faculty
#> 6 -0.347 0.340 -0.488 | 6 rk_intl_students
# decomposition returns pure eigenvectors
get_conference(qs_eigen)
#> [1] 0 0