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

Ability to ignore "not enough finite observations" error #100

Closed
ymer opened this issue Sep 17, 2020 · 5 comments
Closed

Ability to ignore "not enough finite observations" error #100

ymer opened this issue Sep 17, 2020 · 5 comments
Labels
feature idea 🔥 New feature or request

Comments

@ymer
Copy link

ymer commented Sep 17, 2020

correlation calls cor.test.default which gives a not enough finite observation error when applicable. I think there could be a value in correlation() such as ignore_errors that sets those to NA instead.

@DominiqueMakowski
Copy link
Member

Hi, would you have a reproducible example so that we can resolve that? Thanks!

@ymer
Copy link
Author

ymer commented Sep 22, 2020

library(tidyverse)
library(correlation)

tibble(v2 = c(2, 1, 1, 2), v3 = c(1,2, NA, NA)) %>% 
    correlation()

@DominiqueMakowski
Copy link
Member

Yes, that's because you can't compute a correlation with only 2 observations (2 complete rows). If you add one row it works:

library(tidyverse)
#> Warning: package 'tibble' was built under R version 4.0.2
library(correlation)

tibble(v2 = c(2, 1, 1, 2, 2), v3 = c(1,2,  NA, NA, 3)) %>% 
  correlation()
#> Parameter1 | Parameter2 |    r |    t | df |      p |  Method | n_Obs
#> ---------------------------------------------------------------------
#> v2         |         v3 | 0.00 | 0.00 |  1 | > .999 | Pearson |     3

Created on 2020-09-22 by the reprex package (v0.3.0)

@ymer
Copy link
Author

ymer commented Sep 22, 2020

I understand why it can't be calculated. I am interested in the ability to ignore it.

For example, say I have a table with 1000 elements and would like to calculate all correlations. It would be very easy to use correlation::correlation() for that. But if some pairs have too few observations, it gives this error, so the method can't be used.

@DominiqueMakowski
Copy link
Member

I see! Indeed, it would be better to return NA with a warning than throw an error that stops the process. Let me see what I can do.

@DominiqueMakowski DominiqueMakowski added the feature idea 🔥 New feature or request label Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature idea 🔥 New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants