序数数据(Likert量表)因子分析在R中报错及Promin旋转可用性问询
Hey there! Let's work through your factor analysis issues with Likert-scale ordinal data step by step.
First: Fixing the 'Cov' is not symmetric Error & NaNs produced Warnings
These issues almost always stem from two common pitfalls with your input data or analysis setup:
1. You’re including the patient ID column in your analysis
Patient IDs are nominal identifiers—they have no ordinal structure, which breaks the polychoric correlation calculation (it’s designed exclusively for ordered categorical variables). Including this column will mess up the correlation matrix, making it asymmetric, and cause log(P) NaNs when the code tries to compute probabilities for non-ordinal data.
Fix: Drop the ID column before running the analysis. For example, if your data frame is named df and the ID column is called patient_id, use:
# Isolate only the Likert-scale questionnaire items questionnaire_data <- df[, !names(df) %in% c("patient_id")] # Now run the factor analysis on the cleaned data fa(questionnaire_data, cor = "poly", fm = "minrank", nfactors = YOUR_FACTOR_COUNT)
2. Extreme response distributions in some questionnaire items
If any item has zero variability (e.g., every respondent chose the same score, like all 5s), the polychoric correlation calculation will hit a log(0) scenario (producing NaNs) and generate an invalid correlation matrix.
Fix:
- First, check the distribution of each item:
# Print frequency tables for all questionnaire items apply(questionnaire_data, 2, table) - Remove any items with no variation, or verify if the data entry for those items was correct.
3. Debug with step-by-step calculation
If the above fixes don’t work, break the process into two steps to isolate the issue:
# Step 1: Compute the polychoric correlation matrix separately library(psych) poly_cor <- polychoric(questionnaire_data)$rho # Check if the matrix is symmetric (this should return TRUE) isSymmetric(poly_cor) # Step 2: Run minrank factor analysis on the valid correlation matrix fa_result <- fa(r = poly_cor, nfactors = YOUR_FACTOR_COUNT, fm = "minrank", rotate = "promax")
This lets you confirm if the problem is with the correlation calculation or the factor analysis step itself.
Second: Does R support Promin rotation?
Yes! Promin rotation is essentially the same as Promax rotation (a common terminology overlap). The psych package’s fa() function supports it directly with the rotate = "promax" parameter. Just add it to your code:
fa(questionnaire_data, cor = "poly", fm = "minrank", nfactors = YOUR_FACTOR_COUNT, rotate = "promax")
Promax is the standard oblique rotation method for ordinal data factor analysis, so it’ll meet your needs perfectly.
Bonus Debug Tips
- Ensure all questionnaire items are stored as integers or factors (not character strings). Use
str(questionnaire_data)to check, and convert withas.factor()oras.integer()if needed. - If you still get NaNs when calculating polychoric correlations, try adjusting the calculation parameters:
Disabling standard error calculation (poly_cor <- polychoric(questionnaire_data, std.err = FALSE, threshold = "quantile")$rhostd.err = FALSE) can suppress harmless warnings, while adjusting the threshold method may resolve edge-case distribution issues.
内容的提问来源于stack exchange,提问作者Denver Dang

