| check_efa | R Documentation |
Checks whether the specified features in a data frame meet basic criteria for performing exploratory factor analysis (EFA). The function verifies that each feature exists, is numeric, has sufficient variability, and does not have an excessive proportion of missing values. For multiple features, it also evaluates whether the correlation matrix is full rank and whether each feature has at least one sufficiently strong intercorrelation with another feature.
check_efa(
df,
features,
min_unique = 5,
min_intercorrelation = 0.3,
max_missing_rate = 0.05,
verbose = FALSE
)
df |
A dataframe containing the features. |
features |
A character vector of feature names to be evaluated. |
min_unique |
An integer specifying the minimum number of unique non-missing values required for a feature. Default is 5. |
min_intercorrelation |
A numeric threshold for the minimum acceptable intercorrelation among features. (Note: this parameter is not used explicitly in the current implementation.) Default is 0.3. |
max_missing_rate |
A numeric threshold for maximum missing values. Features that have a higher missing rate than this threshold will be flagged. |
verbose |
Logical; if |
The function performs several checks:
Verifies that each feature in features is present in df.
Checks that each feature is numeric.
Ensures that each feature has at least min_unique unique non-missing values.
Flags features with more than 20% missing values.
If more than one feature is provided, the function computes the correlation matrix (using pairwise complete observations) and checks:
Whether the correlation matrix is full rank. A rank lower than the number of features indicates redundancy.
Identifies features that do not have any correlation (>= 0.4) with the other features.
TRUE if all features are deemed suitable for EFA, and FALSE
otherwise. In the latter case, messages detailing the issues are printed.
E. F. Haghish
# Example: assess feature suitability for EFA using the USJudgeRatings dataset.
# this dataset contains ratings on several aspects of U.S. federal judges' performance.
# Here, we check whether these rating variables are suitable for EFA.
data("USJudgeRatings")
features_to_check <- colnames(USJudgeRatings[,-1])
result <- check_efa(
df = USJudgeRatings,
features = features_to_check,
min_unique = 3,
verbose = TRUE
)
# TRUE indicates the features are suitable.
print(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.