pcorstarsl: Partial correlation matrix with singificance stars

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/pcorstarsl.R

Description

Format a partial correlation matrix with stars to indicate significance

Usage

1
pcorstarsl(pcm, n, np, digits = 2, full = FALSE)

Arguments

pcm

A partial correlation matrix

n

Sample size on which the partial correlation matrix pcm was computed.

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.

Details

P-values for partial correlations are computed using function corr.test

Value

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.

Note

This funciton was adapted from here: https://github.com/kyuni22/ksmv/blob/master/functions/corstarsl.R

Author(s)

Giulio Costantini

References

https://github.com/kyuni22/ksmv/blob/master/functions/corstarsl.R

See Also

rcorr corr.test corstarsl

Examples

 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)

GiulioCostantini/markerIndex documentation built on March 3, 2021, 5:58 a.m.