Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pairwise_cor() and p value of correlations #46

Open
ghost opened this issue Dec 13, 2022 · 1 comment
Open

pairwise_cor() and p value of correlations #46

ghost opened this issue Dec 13, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 13, 2022

Dear,
Thank you for this package, which I am using to measure correlations between words. Pairwise co-occurrence between words that co-occur in the same posts from social media. However, I want to extract the p-value of these correlations, I wonder how I can use the package to do that. Thank you David for this tutorial : https://www.youtube.com/watch?v=mApnx5NJwQA
Here is the code for my correlations (line is the id of the post)
correlatee <- data2 %>%
group_by(word) %>%
pairwise_cor(word, line, sort = TRUE, upper = FALSE)
Thank you

@juliasilge
Copy link
Owner

In its current implementation, pairwise_cor() only computes a correlation, like stats::cor():

widyr/R/pairwise_cor.R

Lines 64 to 68 in a6696d6

f <- if (sparse) {
function(x) cor_sparse(t(x))
} else {
function(x) stats::cor(t(x), method = method, use = use)
}

It does not do a test like stats::cor.test(). This is sort of related to #36, where you are interested in a pairwise computation of something beyond the main quantity returned. We could think through how to return other, more complete info in the tidy format we use in this package.

In the meantime, I suggest that you use cor.test() together with broom and purrr for a more manual and customizable approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant