While we expect variation across our sample we’re interested in whether the differences between the means by grouping of transmission type and cylinders is significantly different than what we would expect in random variation across the data. Let’s imagine that the mtcars data set is actually a random sample of 32 cars from different manufacturers and use the mean mpg grouped by am and cyl to help inform our thinking. Imagine that you are interested in understanding whether a car’s fuel efficiency (mpg) varies based upon the type of transmission (automatic or manual) and the number of cylinders the engine has. It’s real strength ( I hope) lies in the fact that it is pulled together in one function and more importantly allows you to visualize the results concurrently with no additional work. The Plot2WayANOVA function conducts a classic analysis of variance (ANOVA) in a sane and defensible, albeit opinionated, manner, not necessarily the only one. If you prefer a more regression based approach with a very similar plotted result I highly recommend the interactions package which I was unaware of until just recently. The 2 Way ANOVA allows for comparisons of mean differences across 2 independent variables factors with a varying numbers of levels in each factor. It is also true that ANOVA is a special case of the GLM or regression models so as the number of levels increase it might make more sense to try one of those approaches. The ANOVA (Analysis of Variance) family of statistical techniques allow us to compare mean differences of one outcome (dependent) variable across two or more groups (levels) of one or more independent variables (factor). DescTool::PostHocTest for accomplishing post hoc tests.broomExtra::glance will also help us grab very important results like \(R^2\) and display them.Prior to this version I had been using my own local function but this runs rings around what I could do. sjstats which takes out ANOVA table and gives us other important information such as the effect sizes ( \(\eta^2\) and \(\omega^2\) ) through use of its anova_stats function.car for it’s ability to compute Type II sums of squares, we’ll address why that’s important in more detail later in the scenario.ggplot2 as the work horse for all the actual plotting.The function makes use of the following non base r packages. I always try and find the right balance between keeping the number of dependencies to a minimum and not reinventing the wheel and writing functions that others have done for me. Plot2WayANOVA, which as the name implies conducts a 2 way ANOVA and plots the results. This vignette covers one function from the package that tries to help users (especially students) do one thing well by pulling together pieces from a variety of places in R. They typically are not “new” methods but rather wrappers around either base R or other packages and are very task focused. I only write functions when I have a real need – no theory – just help for actually practicing the art. The CGPfunctions package includes functions that I find useful for teaching statistics especially to novices (as well as an opportunity to sharpen my own R skills).
0 Comments
Leave a Reply. |