jmv – one R package (not just) for the social sciences
Posted on December 6, 2017 by Jonathon Love in R bloggers | 0 Comments
[This article was first published on jamovi, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
many analyses in the social sciences require many R packages
jmv makes these common analyses available from one R package
jmv can be used from jamovi, a graphical statistical spreadsheet, making it super-accessible
introducing jmv
There are many tremendously useful R packages for the social sciences (and similar fields), such as car, afex vcd, etc. Although running basic analyses (such as t-tests or ANOVA) with these packages is very straight forward, it is typically necessary to perform a number of supplementary analyses to accompany them; post-hoc tests, effect-size calculations, bias-corrections, and assumption checks. These additional tests often require the use of many additional R packages, and can make reasonably standard analyses quite time-consuming to perform. For example, in the book Discovering Statistics Using R by Andy Field (a popular textbook in the social sciences), the chapter on ANOVA alone recommends the use of 7 packages.
jmv simplifies this whole process by bringing all of these packages together and makes doing the following analyses with their most common supplementary tests, corrections and assumption checks as easy as possible:
T-Tests
ANCOVA
Repeated Measures ANOVA
Non-parametric ANOVAs
Contingency Tables
Proportion Tests
Factor Analysis
and coming soon:
Log-linear Regression
jmv aims to make all common statistical tests taught at an undergraduate level available from a single package.
An ANOVA
Let's begin with a simple, familiar analysis – an ANOVA. In this example we use the ToothGrowth dataset from R, and explore whether different food supplements and their dosage affect how much a guinea pig's teeth grow. We'll specify len to be the dependent variable, and supp and dose to be the factors.
<span class="n">library</span><span class="p">(</span><span class="s1">'jmv'</span><span class="p">)</span><span class="w">
</span><span class="n">data</span><span class="p">(</span><span class="s1">'ToothGrowth'</span><span class="p">)</span><span class="w">
</span><span class="n">jmv</span><span class="o">::</span><span class="n">anova</span><span class="p">(</span><span class="n">ToothGrowth</span><span class="p">,</span><span class="w">
</span><span class="n">dep</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'len'</span><span class="p">,</span><span class="w">
</span><span class="n">factors</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="s1">'supp'</span><span class="p">,</span><span class="w"> </span><span class="s1">'dose'</span><span class="p">))</span><span class="w">
##  ANOVA
##  ───────────────────────────────────────────────────────────────────────
##                 Sum of Squares    df    Mean Square    F        p
##    supp                    205     1          205.4    15.57    < .001
##    dose                   2426     2         1213.2    92.00    < .001
##    supp:dose               108     2           54.2     4.11     0.022
##    Residuals               712    54           13.2
This produces what should be a familiar ANOVA table. You have likely seen something like this in R before, though perhaps not as nicely formatted.
Where jmv really comes into its own, is with additional options. In the following example we will perform the same analysis, but additionally requesting effect-size, post-hoc tests, homogeneity of variances tests, descriptive statistics, and a descriptives plot:
</span><span class="n">factors</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="s1">'supp'</span><span class="p">,</span><span class="w"> </span><span class="s1">'dose'</span><span class="p">),</span><span class="w">
</span><span class="n">effectSize</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'eta'</span><span class="p">,</span><span class="w">
</span><span class="n">postHoc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="s1">'supp'</span><span class="p">,</span><span class="w"> </span><span class="s1">'dose'</span><span class="p">),</span><span class="w">
</span><span class="n">plotHAxis</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'dose'</span><span class="p">,</span><span class="w">
</span><span class="n">plotSepLines</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'supp'</span><span class="p">,</span><span class="w">
</span><span class="n">descStats</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">TRUE</span><span class="p">,</span><span class="w">
</span><span class="n">homo</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">TRUE</span><span class="p">)</span><span class="w">
##  ────────────────────────────────────────────────────────────────────────────────
##                 Sum of Squares    df    Mean Square    F        p         η²
##    supp                    205     1          205.4    15.57    < .001    0.059
##    dose                   2426     2         1213.2    92.00    < .001    0.703
##    supp:dose               108     2           54.2     4.11     0.022    0.031
##  ASSUMPTION CHECKS
##  Test for Homogeneity of Variances (Levene's)
##  ────────────────────────────────────────────
##    F       df1    df2    p
##    1.94      5     54    0.103
##  POST HOC TESTS
##  Post Hoc Comparisons - supp
##  ────────────────────────────────────────────────────────────────────────────
##    supp         supp    Mean Difference    SE       df      t       p-tukey
##    OJ      -    VC                 3.70    0.938    54.0    3.95    < .001
##  Post Hoc Comparisons - dose
##  ─────────────────────────────────────────────────────────────────────────────
##    dose         dose    Mean Difference    SE      df      t         p-tukey
##    0.5     -    1                 -9.13    1.15    54.0     -7.95    < .001
##            -    2                -15.50    1.15    54.0    -13.49    < .001
##    1       -    2                 -6.37    1.15    54.0     -5.54    < .001
##  Descriptives
##  ───────────────────────────────────────
##    supp    dose    N     Mean     SD
##      OJ     0.5    10    13.23    4.46
##      OJ       1    10    22.70    3.91
##      VC     0.5    10     7.98    2.75
##      VC       1    10    16.77    2.52
As can be seen, jmv can provide many additional tests and statistics relevant to the main tests, but with far less effort.
You can explore additional options for the jmv ANOVA here, and the other tests and their available options here.
jamovi integration
jmv is also useable from the jamovi statistical spreadsheet. jamovi makes a range of analyses accessible to a broader audience by making them available from a familiar, spreadsheet user-interface. jamovi can also make the underlying R code for each analysis available, making it easy for people to learn R, and transition to R scripting if they like.
Here is exactly the same analysis as above, having been performed in jamovi.
jmv makes a whole suite of common analyses from the social sciences very easy to perform
jamovi makes these even easier to perform
jmv is available from CRAN
jamovi is available from www.jamovi.org
To leave a comment for the author, please follow the link and comment on their blog: jamovi.