Learn R Programming

SciencesPo (version 0.11.21)

rprob: Produces Pairwise Correlation and its Probability

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

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.

Value

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

    references{

    %TODO verify other sourcesAldrich, John (1995) Correlations Genuine and Spurious in Pearson and Yule. emph{Statistical Science,} bold{10(4),} 364--376.

    } author{Daniel Marcelino }

    ote{You can print the whole matrix using code{cor(t(x))}. }

    seealso{code{rstack}. } examples{ 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.

    } keyword{ tables } keyword{ descriptive stats }

encoding

UTF-8

Details

The connexion between correlation and t-statistics is known to be $t = \frac{r \sqrt{(n-2)}} {\sqrt{(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.