Description Usage Arguments Details Value Note Author(s) References See Also Examples
Format a partial correlation matrix with stars to indicate significance
1  | pcorstarsl(pcm, n, np, digits = 2, full = FALSE)
 | 
pcm | 
 A partial correlation matrix  | 
n | 
 Sample size on which the partial correlation matrix   | 
np | 
 Number of variables partialled out  | 
digits | 
 number of decimal places to use  | 
full | 
 logical. If TRUE, a more complete output is returned, including not only the formatted partial correlation matrix, but also the original partial correlations and p-values.  | 
P-values for partial correlations are computed using function corr.test
if full is false, a formatted partial correlation matrix is returned. Otherwise, a list including the formatted partial correlation matrix, the original partial correlaitons and the p-values.
This funciton was adapted from here: https://github.com/kyuni22/ksmv/blob/master/functions/corstarsl.R
Giulio Costantini
https://github.com/kyuni22/ksmv/blob/master/functions/corstarsl.R
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  | library(psychTools)
library(corpcor)
data(bfi)
# compute correlation matrix using listwise deletion
cm <- cor(bfi[,1:10], use = "complete.obs")
# convert it to partial correlation matrix, using funciton cor2pcor in package corpcor
pcm <- cor2pcor(cm)
# include variable names in the partial correlation matrix
colnames(pcm) <- rownames(pcm) <- colnames(cm)
# determine sample size as the number of cases without missing values
n <- sum(rowSums(is.na(bfi)) == 0)
# format the partial correlation matrix.
# parameter np is set to eight, because from each correlation between two variables
# all remaining eight variables were partialled out
pcorstarsl(pcm, n, np = 8)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.