# Dale Barr's Blog

## Categorical variables in regression for factorial experiments

- Details
- Created on 27 March 2013
- Last Updated on 30 January 2014
- Written by Dale Barr
- Hits: 1907

Many experimentalists who are trying to make the leap from ANOVA to regression in R struggle with the coding of categorical predictors. It is unexpectedly complicated, and the defaults provided in R turn out to be wholly inappropriate for factorial experiments. Indeed, using those defaults with factorial experiments can lead researchers to draw erroneous conclusions from their data.

I have limited the discussion below to factorial designs in which all factors have exactly 2 levels. I will update the post later with info on more complex cases. The general principles and recommendations put forward here also hold for those cases.

## Keeping It Maximal

- Details
- Created on 03 July 2012
- Last Updated on 19 August 2016
- Written by Dale Barr
- Hits: 4036

My co-authors and I (Roger Levy, Christoph Scheepers, and Hal Tily) recently published a manuscript discussing the use of various random-effects structures in linear mixed-effects models, which can be downloaded using the link below. The paper has some new results demonstrating that models including the maximal random-effects structure actually have surprisingly good statistical power, a discussion of how to cope with nonconverging models, as well as a survey of the best methods for calculating p-values from fitted lmer objects. There is also an online appendix with extensive discussion and additional analysis.

UPDATE (Oct 30, 2012): the link below is now to the second revised version of the manuscript

UPDATE (Nov 8, 2012): the paper is now in press at JML

UPDATE (Jan 2013): the paper is now published; preprint is here, published version is here

Citation:

Barr, D. J., Levy, R., Scheepers, C., & Tily, H. J. (in press). Random-effects structure for confirmatory hypothesis testing: Keep it maximal. *Journal of Memory and Language, 68, *255-278.

## Why log odds?

- Details
- Created on 03 December 2010
- Last Updated on 19 August 2016
- Written by Dale Barr
- Hits: 1324

Another re-post from my previous website looking into the issue of why we might want to consider using the log odds scale with categorical data.

## Walkthrough of an

- Details
- Created on 06 November 2010
- Last Updated on 19 August 2016
- Written by Dale Barr
- Hits: 3720

This is a walkthrough of how to perform a quasi-logistic regression on visual world eyetracking data in R. It is revised and improved from an earlier version.

## Controlling for anticipatory effects experimentally

- Details
- Created on 03 December 2010
- Last Updated on 19 August 2016
- Written by Dale Barr
- Hits: 1386

Here is a re-posting of a walkthrough (Oct. 2007) of how to control for anticipatory baseline effects experimentally. Looking at it today, there are two things I would do differently. First, I would use random slopes for subjects and items. Second, I would use permutation tests rather than the quasi-logit approximation. Re-running the code today with an updated lme4 package gives me drastically different results than what I got in 2007, which worries me.

I hope to post soon about a new R package I have developed (gmpm) which enables estimation of p-values for an MLR model using permutation tests. If you want to try out the new approach, install the package gmpm from R-forge like this:

`install.packages("gmpm", repos="http://R-Forge.R-project.org")`

Then have a look at the kb07 walkthrough (just type ?kb07 at the command line).