R语言中tab_corr与apa.cor.table输出相关值差异的原因排查
Possible Reasons & Fixes for Correlation Value Discrepancy Between
tab_corr and apa.cor.table Most Likely Cause: Accidental Use of Raw Data Instead of Precomputed Correlation Matrix
The biggest culprit here is probably a typo in your apa.cor.table call: if you passed the raw data frame instead of corrmatrix, apa.cor.table uses listwise deletion by default (dropping any row with missing values in any variable). This differs from the pairwise.complete.obs method you used to compute corrmatrix, where each correlation pair uses all available data for that specific pair. If cases with missing values tend to have lower correlations, listwise deletion would exclude those rows, resulting in higher overall correlation values (0.8-0.9 range) compared to pairwise (0.5-0.7).
Other Possible Causes
- Misreading the Output: Double-check that you’re looking at the correlation column in
apa.cor.table’s output, not confidence interval bounds, p-values, or other statistics. - Outdated Package Version: A bug in an older version of the
apaTablespackage could cause unexpected behavior. - Overwritten
corrmatrix: Ensure thecorrmatrixobject in your environment hasn’t been overwritten by another variable with the same name (though this is less likely sincetab_corrmatches its values).
Actionable Advice
- Verify Your Code: Confirm you’re running
apa.cor.table(corrmatrix)and notapa.cor.table(data). - Inspect the Correlation Matrix: Run
print(corrmatrix)to explicitly check that its values are indeed in the 0.5-0.7 range. - Update
apaTables: Install the latest version with:install.packages("apaTables") - Use Pairwise Deletion with Raw Data (If Needed): If you want to compute correlations directly from
datausing pairwise deletion inapa.cor.table, specify thena.actionargument:
This will match the correlation calculation method used for yourapa.cor.table(data, na.action = na.pairwise)corrmatrix.
内容的提问来源于stack exchange,提问作者Laura Ashlock
相关产品推荐
相关产品推荐

