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

Misaligned mean difference line #29

Closed
johannesbjork opened this issue Mar 1, 2019 · 5 comments · Fixed by #43
Closed

Misaligned mean difference line #29

johannesbjork opened this issue Mar 1, 2019 · 5 comments · Fixed by #43
Assignees
Labels
bug Something isn't working
Milestone

Comments

@johannesbjork
Copy link

When plotting proportional data, I found that the mean difference line is not aligned to the mean difference distribution.

Here is an example.

df <- cbind(data.frame(value=sample(1:9, 100, replace= TRUE)/10),data.frame(grp=sample(c("A","B"),100,replace=T)))

plot(dabest(df, x = grp, y = value, idx = c("A","B")))

screen shot 2019-02-28 at 10 47 24 pm

@josesho josesho added the bug Something isn't working label Mar 1, 2019
@josesho josesho added this to the v0.3.0 milestone May 28, 2019
@josesho josesho self-assigned this May 28, 2019
@josesho
Copy link
Member

josesho commented Jun 26, 2019

Sorry for the delay. I'm seeing this on my end as well; definitely a bug.

You can use www.estimationstats.com to produce the correct Gardner-Altman plot.

Will let you know once I've squashed this bug!

PS. We are working on more effective ways to display proportions. (Here, I assume each data point is a proportion already?)

@josesho
Copy link
Member

josesho commented Jun 26, 2019

More troubleshooting.

library(tidyverse)

set.seed(12345)
df <- cbind(data.frame(value=sample(1:9, 100, replace = TRUE)/10), 
            data.frame(grp=sample(c("A","B"), 100, replace = T))
            )
df %>% group_by(grp) %>% count()
# A tibble: 2 x 2
# Groups:   grp [2]
  grp       n
  <fct> <int>
1 A        54
2 B        46

Using dabestr to analyse this....

library(dabest)

df_analysed <- dabest(df, x = grp, y = value, idx = c("A", "B"))
df_analysed

produces

DABEST (Data Analysis with Bootstrap Estimation) v0.2.1
============================================================

Variable: value 

Unpaired mean difference of B (n=54) minus A (n=100)
 -0.0127 [95CI  -0.0986; 0.0774]


5000 bootstrap resamples.
All confidence intervals are bias-corrected and accelerated.

Note how the N for A is now 100 instead of 54. The bug likely lies in how the data.frame is being handled....

@josesho
Copy link
Member

josesho commented Jun 26, 2019

This is likely to be related to #30 . For some reason, unequal group sizes jams up the munging....

@josesho
Copy link
Member

josesho commented Jun 26, 2019

Hi @johannesbjork ,

This bug occurs because grp is used internally. To quickly and simply mitigate this, simply change the x-column to another name.

library(dabest)

set.seed(12345)
df <- cbind(data.frame(value=sample(1:9, 100, replace = TRUE)/10), 
           # we rename the `grp` column to `ggrp`.
            data.frame(ggrp=sample(c("A","B"), 100, replace = T)) 
)


df_analysed <- dabest(df, x = ggrp, y = value, idx = c("A", "B"))
plot(df_analysed)

out

@josesho josesho modified the milestones: v0.3.0, v0.2.2 Jun 26, 2019
@josesho josesho mentioned this issue Jun 27, 2019
@josesho
Copy link
Member

josesho commented Jun 28, 2019

Pull request #43 fixes this. Run

devtools::install.github('ACCLAB/dabestr')

to install v0.2.1.9000, which is the beta release. This should be on CRAN in a week or so.

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

Successfully merging a pull request may close this issue.

2 participants