8000 polychoric correlation method yields error · Issue #347 · easystats/correlation · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

polychoric correlation method yields error #347

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

Open
jschoeneberger opened this issue Apr 10, 2025 · 4 comments
Open

polychoric correlation method yields error #347

jschoeneberger opened this issue Apr 10, 2025 · 4 comments
Labels
bug 🐛 Something isn't working

Comments

@jschoeneberger
Copy link
jschoeneberger commented Apr 10, 2025

I have ordinal data and want to estimate a polychoric correlation matrix (and export to Excel). However, when I submit my data to the procedure with method="polychoric" i get:

dat <- c(1, 1, 1, 1, 0,
         1, 1, 1, 2, 1,
         1, 2, 1, 2, 0,
         1, 1, 0, 2, 0,
         2, 2, 2, 2, 1,
         1, 1, 2, 2, 1,
         1, 0, 0, 0, 1,
         1, 1, 0, 1, 1,
         1, 1, 1, 1, 0,
         1, 1, 1, 1, 1)
df <- data.frame(matrix(dat,ncol=5, byrow=T))
correlation::correlation(df, method = "polychoric")
#> Error: No random effects terms specified in formula. 
@mattansb
Copy link
Member

That is a weird error...

For now, the fix would be to convert the input data to an ordered factor:

dat <- c(1, 1, 1, 1, 0,
         1, 1, 1, 2, 1,
         1, 2, 1, 2, 0,
         1, 1, 0, 2, 0,
         2, 2, 2, 2, 1,
         1, 1, 2, 2, 1,
         1, 0, 0, 0, 1,
         1, 1, 0, 1, 1,
         1, 1, 1, 1, 0,
         1, 1, 1, 1, 1)
df <- data.frame(matrix(dat,ncol=5, byrow=T))

# Convert all columbs to ordered factors:
df[] <- lapply(df, ordered)

correlation::correlation(df, method = "polychoric")
#> # Correlation Matrix (polychoric-method)
#> 
#> Parameter1 | Parameter2 |      rho |        95% CI |   t(8) |         p
#> -----------------------------------------------------------------------
#> X1         |         X2 |     0.24 | [-0.46, 0.75] |   0.69 | > .999   
#> X1         |         X3 |     0.37 | [-0.34, 0.81] |   1.13 | > .999   
#> X1         |         X4 |    -0.03 | [-0.65, 0.61] |  -0.08 | > .999   
#> X1         |         X5 |     0.98 | [ 0.92, 1.00] |  13.99 | < .001***
#> X2         |         X3 |     0.77 | [ 0.26, 0.94] |   3.36 | 0.079    
#> X2         |         X4 |     1.00 | [ 1.00, 1.00] | 312.31 | < .001***
#> X2         |         X5 |    -0.13 | [-0.70, 0.54] |  -0.37 | > .999   
#> X3         |         X4 |     0.69 | [ 0.11, 0.92] |   2.70 | 0.189    
#> X3         |         X5 |     0.11 | [-0.56, 0.69] |   0.30 | > .999   
#> X4         |         X5 | 9.15e-03 | [-0.62, 0.64] |   0.03 | > .999   
#> 
#> p-value adjustment method: Holm (1979)
#> Observations: 10

Created on 2025-04-18 with reprex v2.1.1

8000

@mattansb mattansb added the bug 🐛 Something isn't working label Apr 18, 2025
@Nicosiane
Copy link

Little OT: Why are most of the p-Values >.999 when rho clearly is not 0?

@strengejacke
Copy link
Member

Due to the large confidence intervals

@Nicosiane
Copy link

Sorry, haven't noticed p_adjust = 'holm'.
Thanks for replying and thanks for your extremely valuable work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants
0