rprob: Produces Pairwise Correlation and its Probability

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

Description

Computes the pairwise correlations for all valid cases (!NA) in a data frame and find the probabilities for each combination. This function parses the correlations below the diagonal and the significance probabilities above it.

Usage

1
rprob(x, df = nrow(x) - 2)

Arguments

x

A data object.

df

an optional value for degrees of freedom. The default assumes you have a common degrees of freedom (n-2) for all correlations in the table.

Details

The connexion between correlation and t-statistics is known to be t = \frac{r √{(n-2)}} {√{(1-r^2)}}. Or then, F = t^2 = r^2 * (n - 2)/(1 - r^2) ~ F(1, n-2). By solving this, it is possible to find the probabilities.

Value

A data frame object with the Pearson's product-moment coefficient and its probabilitie. The first diagonal display the correlations, while the probabilities are shown in the second uppper diagonal.

Note

You can print the whole matrix using cor(t(x))

Author(s)

Daniel Marcelino

References

Aldrich, John (1995) Correlations Genuine and Spurious in Pearson and Yule. Statistical Science, 10(4), 364–376.

See Also

rstack.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
data(nerlove63)

rprob(nerlove63)

# a stacked up table

rstack(rprob(nerlove63)) 

summary(lm(output ~ plabor + totcost, data = nerlove63))

# The final p-value of the OLS compares to the probabilities in the
# intersection of output and plabor and output and totcost in the matrix.

SciencePo documentation built on May 2, 2019, 5:53 p.m.