AntoineSoetewey / statsandr

A blog on statistics and R aiming at helping academics and professionals working with data to grasp important concepts in statistics and to apply them in R. See www.statsandr.com
http://statsandr.com/
35 stars 15 forks source link

blog/how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way/ #27

Closed utterances-bot closed 3 years ago

utterances-bot commented 3 years ago

How to do a t-test or ANOVA for more than one variable at once in R - Stats and R

Learn how to compare samples for multiple variables at once in R thanks to a Student t-test or ANOVA and communicate the results in a better way

https://statsandr.com/blog/how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way/

AntoineSoetewey commented 3 years ago

Comment written by CARLOS ORTEGA on March 19, 2020 19:59:08:

Thanks for your entry, very elaborated and clear.
For further reference, and I used it very recently, I strongly recommend you to take a look to "compareGroups" package.

It will make the first analysis (not the graphical one) automatically even if the dataset includes categoricals.
https://cloud.r-project.org/web/packages/compareGroups/index.html

Thanks again,
Carlos.

AntoineSoetewey commented 3 years ago

Comment written by Duleep Samuel on March 20, 2020 08:02:54:

thanks for sharing a very useful site

AntoineSoetewey commented 3 years ago

Comment written by Duleep Samuel on March 20, 2020 08:02:54:

thanks for sharing a very useful site

Comment written by Antoine Soetewey on March 20, 2020 08:05:25:

Glad you like it!

AntoineSoetewey commented 3 years ago

Comment written by CARLOS ORTEGA on March 19, 2020 19:59:08:

Thanks for your entry, very elaborated and clear. For further reference, and I used it very recently, I strongly recommend you to take a look to "compareGroups" package.

It will make the first analysis (not the graphical one) automatically even if the dataset includes categoricals. https://cloud.r-project.org/web/packages/compareGroups/index.html

Thanks again, Carlos.

Comment written by Antoine Soetewey on March 20, 2020 09:38:54:

Thanks Carlos for your comment.

I added a reference to the package you mentioned, but I'll definitely discuss it in more details in an article about descriptive statistics and/or about presenting odds ratio.

Regards, Antoine

AntoineSoetewey commented 3 years ago

Comment written by Chuck Powell on March 20, 2020 12:18:19:

Take a look at ggstatsplot (https://github.com/IndrajeetPatil/ggstatsplot) [full disclosure I contributed a small amount to the package in the past]

AntoineSoetewey commented 3 years ago

Comment written by Chuck Powell on March 20, 2020 12:18:19:

Take a look at ggstatsplot (https://github.com/IndrajeetPatil/ggstatsplot) [full disclosure I contributed a small amount to the package in the past]

Comment written by Antoine Soetewey on March 20, 2020 14:58:17:

The package is really complete, thanks for your input Chuck!

I have mentioned it in the article and I'll definitely discuss about it again in a future article.

AntoineSoetewey commented 3 years ago

Comment written by Shodan on April 02, 2020 17:16:00:

Thank you for this I have found it very helpful. However, I have some questions.

Questions

Any help interpreting these graphs would be very helpful.

Thank you. Jason, the #rstatsnewbie

AntoineSoetewey commented 3 years ago

Comment written by Shodan on April 02, 2020 17:16:00:

Thank you for this I have found it very helpful. However, I have some questions.

Questions

  • In the first graph, is the top value shown "1.9e-07" a p-value?
  • If so, why isn't it written out as such?
  • If son, is it considered significant?
  • If so, why aren't asterisks shown?
  • The second and third numbers are p-values
  • Are they significant?
  • If so, why aren't asterisks shown?
  • What level of significance do the 4 asterisks shown  represent?
  • Could a graph have comparisons with p-values at different levels of significance (e.g., 0.05, 0.01, 0.001 etc.)?

Any help interpreting these graphs would be very helpful.

Thank you. Jason, the #rstatsnewbie

Comment written by Antoine Soetewey on April 03, 2020 08:00:14:

Dear Shodan,

Hope this helps.

Regards, Antoine

AntoineSoetewey commented 3 years ago

Comment written by Pat on May 29, 2020 21:49:01:

I have a question on your ANOVA section for this article. I was under the impression that you couldn't use a t-test multiple times without making a correction to your p value, but the values shown in the graphs are non-adjusted is that right? - EDIT - It looks like you have that addressed in the introductory note on 'multiplicity'.  I'm assuming that since your t-test values are so small, they qualify as fitting the Bonferroni correction for multiple t-tests.

grahamreidpsychology commented 3 years ago

Thank you so much for sharing your code. It is excellent! I have 6 ANOVAS that I want to run on my depedent variable and plot as boxplots. I have written a loop using lapply(), which allows me to run the 6 ANOVAS and plot the boxplots no problem. However, I have no idea how to loop so that I can do the pairwise comparisons and add the significant ones to the boxplots. Would you have any idea how to do this or how to ammend your code (which is similar to mine) to add these comparisons in one loop ?

AntoineSoetewey commented 3 years ago

Thank you so much for sharing your code. It is excellent! I have 6 ANOVAS that I want to run on my depedent variable and plot as boxplots. I have written a loop using lapply(), which allows me to run the 6 ANOVAS and plot the boxplots no problem. However, I have no idea how to loop so that I can do the pairwise comparisons and add the significant ones to the boxplots. Would you have any idea how to do this or how to ammend your code (which is similar to mine) to add these comparisons in one loop ?

Hello,

Hard for me to reply without seeing your code. My code can be used to run ANOVAs and do multiple comparisons, but it will display all comparisons and not just the significant ones.

I believe editing my code to display only the significant comparisons would be too much of a struggle (and not very efficient). However, here are two resources that may be of interest to you:

Hope this helps.

Regards, Antoine