A class on using R
R is a stats software, free and powerful.
It can be downloaded here: http://www.r-project.org
Interested french-speaking readers, can download the slides of the class I taught for several years in our master program.
These slides can be downloaded by clicking the button below:
It can be downloaded here: http://www.r-project.org
Interested french-speaking readers, can download the slides of the class I taught for several years in our master program.
These slides can be downloaded by clicking the button below:
R Ressources:
To get access to the "outliers" function (ranking participants according to their studentized deleted residuals, lever, or Cook D—a function I wrote) and "PRE" function (computing effects sizes for each one of the parameter estimates of a given regression model—a fonction wrote by Fabrice Gabarrot). You can download directly the "MCARfunctions" R package from my GitHub page. To do so, you need to 1) download the "devtools" package (with "install.packages("devtools")", this will give you access to the "install_github" function) and 2) use the following command:
devtools::install_github("mullerd38/MCARfunctions")
As always in R, you will then need to activate the package, for instance, using "library" (this will translate into "library(MCARfunctions)"). Then, the "outliers" and "PRE" functions can be used like this:
outliers(DV~IV, DF)
fit <- lm(DV~IV, DF)
PRE(fit)
By defaults, datasets are ranked by studentized deleted residuals, if you want to ranked them according to levers or Cook D, you can use:
outliers(DV~IV, DF,"lever")
outliers(DV~IV, DF,"cookd")
To get a complete R script with all the commands, click the button just below:
devtools::install_github("mullerd38/MCARfunctions")
As always in R, you will then need to activate the package, for instance, using "library" (this will translate into "library(MCARfunctions)"). Then, the "outliers" and "PRE" functions can be used like this:
outliers(DV~IV, DF)
fit <- lm(DV~IV, DF)
PRE(fit)
By defaults, datasets are ranked by studentized deleted residuals, if you want to ranked them according to levers or Cook D, you can use:
outliers(DV~IV, DF,"lever")
outliers(DV~IV, DF,"cookd")
To get a complete R script with all the commands, click the button just below:
Sometimes, you want to use what can be called the model / residual approach to test a precise pattern of means (See Rosnow & Rosenthal inspiring work). To do so, you come up with a first contrast that captures your predicted patterns (e.g., -3, 1, 1, 1) and k - 2 (k being the number of groups) orthogonal contrasts for the residual variance (e.g., 0, -2, 1, 1, and 0, 0, -1, 1). The problem is that sometimes coming up with the k - 2 contrasts for the residual variance is not that easy (try to find two contrasts orthogonal with, say, -7, -3, 1, 9…). The following R code helps you to find them.
To get this R script, click the button below:
To get this R script, click the button below:
To go further with R
For interested readers who want to go further in discovering R, I recommend the very good book by Robert Muenchen Despite its title, it is worth mentioning I think one does not need to be familiar with SAS or SPSS to learn from this book. Also, it should be noted that this book introduces the base R functions, that means functions built-in R, instead of, say, functions you can access with downloading packages. I think it is worth knowing them before moving to, for instance, the tidyverse.
Speaking of tidyverse, I also recommend R for data science, by Wickham and colleagues. This books introduces the tidyverse, a set of very powerful and coherent packages. It can be accessed for free here: https://r4ds.hadley.nz