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

paired argument in pairwise_t_test and t_test #136

Open
albert-ying opened this issue Dec 2, 2021 · 4 comments
Open

paired argument in pairwise_t_test and t_test #136

albert-ying opened this issue Dec 2, 2021 · 4 comments

Comments

@albert-ying
Copy link

I'm a little bit confused by the name here. Which one should I use if I want to compare the measurements of the same individuals before and after treatment? And also, how does the function identify the "pairs"? There seems to be no argument to specify the ids of the measurements.

Thank you so much!

@wolass
Copy link

wolass commented Jan 24, 2022

you should use t_test(data, formula, paired = TRUE)

the pairwise_t_test is for performing multiple t_tests in many groups like so:

  1. group A vs group B
  2. Group A vs group C
  3. Group B vs group C

@wolass
Copy link

wolass commented Jan 24, 2022

regarding the identifier I guess this is a critical issue.

Right now the way (I think) t_test handles paired data is that it expects the order of each observation to be the same in each group. After it splits them into two vectors the first observation in the first vector (group A) would be corresponding to the first observation in second vector (group B). Of course if you have unordered observations according to origin_id (patient_it, sample_id or etc.) then your two vectors may have different order of observations listed in them and they would not correspond to their pair. Therefore this error prone behaviour should be repaired by adding an identifier variable, or sth like that.

@albert-ying
Copy link
Author

So in the current version, it is actually critical to pre-sort the table based on the ID. Thank you so much @wolass for clarifying!

@BobMuenchen
Copy link

Thanks for all your hard work on rstatix, I love it! One way it could be improved is to accept pairs of variables in some functions rather than requiring a formula. In my experience, it's much safer to enter paired data into two columns, so each row is the same person (or experimental unit). Otherwise, if you miss entering a single cell, the matching between pairs is destroyed. R's built-in function allows this form to handle that common situation:

t.test(mydata$pretest,
mydata$posttest,
paired = TRUE)

It would be helpful if t_test (and wilcox_test) offered that type of variable specification.

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

3 participants