djnavarro / rbook

Source files for "Learning Statistics with R"
https://learningstatisticswithr.com
470 stars 156 forks source link

Help wanted? #17

Open ibecav opened 5 years ago

ibecav commented 5 years ago

Hi,

I've been lurking for a bit and have enjoyed watching you get organized and start tackling this. I'm a long time user of the book and the lsr package in my teaching and actually thanked Danielle on a few occasions.

I'm not sure exactly how often or how much I can be of assistance but if this is indeed one of those cases where many hands make light work versus just add more complexity I'd love to try.

I'm much more a practitioner than a theorist but I do believe I can help even in small ways if you're resolved to move towards the tidyverse. Simple example is the etaSquared issue which was written when there were a lot fewer options out there. There's a nice clean solution in the sjstats package that is tidy and is easily dropped into the book to reinforce the teaching points around types of sums of squares and effect sizes...

Don't want to butt in since you all seem well-organized and moving forward but thought I would ask.

Chuck

xmtcars <- mtcars
xmtcars$cyl <- as.factor(xmtcars$cyl)
xmtcars$am <- as.factor(xmtcars$am)
sjstats::anova_stats(aov(mpg~am*cyl, xmtcars)) #type 1 order matters
#>        term df   sumsq  meansq statistic p.value etasq partial.etasq
#> 1        am  1 405.151 405.151    44.064   0.000 0.360         0.629
#> 2       cyl  2 456.401 228.200    24.819   0.000 0.405         0.656
#> 3    am:cyl  2  25.437  12.718     1.383   0.269 0.023         0.096
#> 4 Residuals 26 239.059   9.195        NA      NA    NA            NA
#>   omegasq partial.omegasq cohens.f power
#> 1   0.349           0.574    1.302 1.000
#> 2   0.386           0.598    1.382 1.000
#> 3   0.006           0.023    0.326 0.298
#> 4      NA              NA       NA    NA
sjstats::anova_stats(aov(mpg~cyl*am, xmtcars)) #type 1 order matters
#>        term df   sumsq  meansq statistic p.value etasq partial.etasq
#> 1       cyl  2 824.785 412.392    44.852   0.000 0.732         0.775
#> 2        am  1  36.767  36.767     3.999   0.056 0.033         0.133
#> 3    cyl:am  2  25.437  12.718     1.383   0.269 0.023         0.096
#> 4 Residuals 26 239.059   9.195        NA      NA    NA            NA
#>   omegasq partial.omegasq cohens.f power
#> 1   0.710           0.733    1.857 1.000
#> 2   0.024           0.086    0.392 0.515
#> 3   0.006           0.023    0.326 0.298
#> 4      NA              NA       NA    NA
sjstats::anova_stats(car::Anova(aov(mpg~am*cyl, xmtcars), type =2))
#>        term   sumsq  meansq df statistic p.value etasq partial.etasq
#> 1        am  36.767  36.767  1     3.999   0.056 0.049         0.133
#> 2       cyl 456.401 228.200  2    24.819   0.000 0.602         0.656
#> 3    am:cyl  25.437  12.718  2     1.383   0.269 0.034         0.096
#> 4 Residuals 239.059   9.195 26        NA      NA    NA            NA
#>   omegasq partial.omegasq cohens.f power
#> 1   0.036           0.086    0.392 0.515
#> 2   0.571           0.598    1.382 1.000
#> 3   0.009           0.023    0.326 0.298
#> 4      NA              NA       NA    NA
sjstats::anova_stats(car::Anova(aov(mpg~am*cyl, xmtcars), type =3))
#>          term    sumsq   meansq df statistic p.value etasq partial.etasq
#> 1 (Intercept) 1573.230 1573.230  1   171.104   0.000 0.762         0.868
#> 2          am   58.430   58.430  1     6.355   0.018 0.028         0.196
#> 3         cyl  167.710   83.855  2     9.120   0.001 0.081         0.412
#> 4      am:cyl   25.437   12.718  2     1.383   0.269 0.012         0.096
#> 5   Residuals  239.059    9.195 26        NA      NA    NA            NA
#>   omegasq partial.omegasq cohens.f power
#> 1   0.754           0.838    2.565 1.000
#> 2   0.024           0.140    0.494 0.712
#> 3   0.072           0.330    0.838 0.975
#> 4   0.003           0.023    0.326 0.298
#> 5      NA              NA       NA    NA

Created on 2019-01-11 by the reprex package (v0.2.1)