Teaching ] Research ] Other Stuff ]

 

Making Within Subjects Confidence Intervals

 

This is the homepage for Wright (2007, BRM).  The paper presents code to create within subjects confidence intervals using procedures made popular by Loftus and Masson (1994, Masson & Loftus, 2003).  The code works only for simple repeated measures designs and does not do anything to take into account complex covariance patterns.  These are meant as graphical aides. A useful recent article, which is available on the web, is Cousineau (2007; http://www.tqmp.org/doc/vol1-1/p42.pdf).

    The code will be updated when appropriate and extensions may be added.  If you want to include information on this page please email me. 

 

   R code        SPSS code        S-Plus code        

 

The R code is the most up-to-date and does the most (and thanks to Reinhold Kliegl for catching some bugs). The SPSS code is the most limited, and it probably most suitable as teaching aide.

 

meth = 0 removes the individual differences and calculates the wsci

meth = 1 does the same but the intervals are bootstrapped

meth = 2 uses the MSsxc and produces the same estimates as L&M (1994)

 

In addition to the functions of the S-Plus code, the R function uses Hmisc's errbar function to graph both the between and within subjects intervals if diff=1. So the following produces the within subject figure from Loftus and Masson (1994) with a between subject graph for comparison., 

 

library(boot)

library(Hmisc)

loftus <- read.table("http://www.sussex.ac.uk//Users//danw//temp//lm.dat",header=T)

attach(loftus)

source("http://www.sussex.ac.uk//Users//danw//WSCI//wsci.R")

wsci(loftus,meth=2,diff=1)

 

produces:

 

 

 

Data sets (in SPSS since that is easily read by S-Plus and R):

    Child.sav (from paper)

    company.sav (from Wright, 1997, Table 6.5).

 

Example graphs from SPSS and S-Plus.

 

    Cousineau, D. (2007). Confidence intervals in within-subjects designs: A simpler solution to Loftus and Masson's method. Tutorials in Quantitative Methods for Psychology, 1, 42-45.

     Loftus, G. R. & Masson, M. E. J. (1994). Using confidence-intervals in within-subject designs. Psychonomic Bulletin & Review, 1, 476-490.

     Masson, M. E. J. & Loftus, G. R. (2003). Using confidence intervals for graphically based data interpretation. Canadian Journal of Experimental Psychology, 57, 203-220.

     Wright, D. B. (1997). Understanding Statistics: An Introduction for the Social Sciences. London : Sage.

     Wright, D. B. (2007). Graphing within subject confidence intervals (WSCI) using SPSS and S-Plus. Behavior Research Methods

 

A recent paper points out that the Loftus and Masson approach makes certain assumptions that may not always be appropriate. It is

 

    Blouin, D. C., & Riopelle, A. J. (2005). On confidence intervals for within-subjects designs. Psychological Methods, 10, 397-412.

 

I haven't incorporated their approach into the code yet. It should be fairly straightforward for the S-Plus/R functions. It involves mixed effect, or multilevel modelling (see here).