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

Comments

@ymer
Copy link

@ymer 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

@DominiqueMakowski DominiqueMakowski commented Sep 18, 2020

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

@ymer
Copy link
Author

@ymer 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

@DominiqueMakowski DominiqueMakowski commented Sep 22, 2020

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 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

@DominiqueMakowski DominiqueMakowski commented Sep 22, 2020

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.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.