Uni Jena
Wirtschaftswissenschaftliche Fakultät
Lehrstuhl für Empirische und Experimentelle Wirtschaftsforschung
[A picture of Oliver Kirchkamp]

Working with experimental data - mixed effects models

This course is part of the International Max Planck Research School on Adapting Behavior in a Fundamentally Uncertain World. The target group are students who, due to the interdisciplinary nature of the IMPRS school, do not have any background in statistics
Schedule:
Lecture (daily): 10.-14.8. (for details, see the calendar)
Motivation
Many, if not all of the students in our program will work with experiments. In most experiments we observe the same unit (participant in the experiment, matching group in the experiment) repeatedly. We say, the data is ``grouped''. Mixed-effect models are a versatile tool to analyse grouped data.
Topics:
  • Introduction
  • Revision: Linear models
  • Linear fixed effects
  • Balanced and unbalanced data
  • Linear random effects
  • Linear mixed effects
  • Nonlinear mixed effects
  • Nested factors
  • Hypothesis tests
  • Correlation structures
  • Sample size estimation
Literature
  • Jose C. Pinheiro and Douglas M. Bates, Mixed Effects Models in S and S-Plus. Springer, 2002.
  • Julian J. Faraway, Extending the Linear Model with R. Chapman & Hall, 2006.
Software
For our practical examples (during the entire course) we will use the software environment R. I think that it is helpful to coordinate on one environment and R has the advantage of being free and rather powerful.
  • Documentation for R is provided via the build in help but also through the R Homepage. Useful is An Introduction to R, The R language definition, Simple R, and Econometrics in R.
  • A first entry into R eased through mice and menues is available through the R Commander.
  • Users of Firefox get access to R help through the R Site Search Sidebar. However, this is a bit tricky. If the rsitesearch.xpi package does not install, open the package (e.g. in Emacs) and change two values in install.rdf: Set maxVersion to a version at least as large as the version of your browser. Set updateURL to an empty value.
  • In the lecture I use the versatile editor Emacs with the ESS interface (ESS also helps with Stata, SAS, Splus, BUGS, and others).
  • It will help if you can bring your own portable computer to the classes and exercises. You should have an up-to-date version of R already installed. You should also have the following libraries already installed: car, Ecdat, Hmisc, nlme, lme4. You should have set up your computer such that you can work with R.
  • You might also find make and Emacs useful tools.
Handout + Exam
I have put a preliminary version of the handout on the net. The data we use for the examples is attached to the handout. Use pdftk or your PDF viewer to extract the data. If you use Adobe Acrobat and you have difficulties saving attachments from PDF files look here.

Please solve the exam between 15:00 on 14th August until 15:00 on 15th August. You will need the data in R format or in Stata format to solve the exam.

For those who are interested in the commands I used in today's exercise:

with(exe2,{
     print(length(unique(player)))
     print(table(player,treatment))
     print(table(treatment))
   })
exe2 <- within(exe2,t<-as.factor(treatment))
lmer(y ~ t -1 + period + (1|player),data=exe2)
And here are some commands that you could have used in the exam. Let us start with a colorful boxplot (not really part of the exam):
with(exam,boxplot(effort ~ Treatment,col=levels(as.factor(Treatment))))
Here is the serious stuff:
summary(lm (effort ~ Treatment - 1,data=exam))
If we are interested in the red treatment, we would rather say
summary(lm (effort ~ (Treatment=="red"),data=exam))
In the lecture I forgot to mention that geeglm needs ordered data (and since I gave you unordered data, in your estimates you got too many clusters):
exam <- exam[with(exam,order(matchingGroup,playerid)),]
summary(r.cluster <- geeglm (effort ~ Treatment - 1,
                                     id=matchingGroup,data=exam))

(lmer.0 <- lmer(effort ~ Treatment - 1 + (1|matchingGroup) + 
                                         (1|playerid),data=exam))
When I asked for a random effect also for treatments (and not only for the intercept) some of you then dropped the fixed effect for Treatment entirely. That was not the idea. What I had in mind was the following:
(lmer.T <- lmer(effort ~ Treatment - 1 + (1+Treatment|matchingGroup) + 
                                     (1+Treatment|playerid),data=exam))

anova(lmer.T,lmer.0)
Here you could explain that anova is anticonservative and that one should better use a permutation test.
hausman(lm(effort ~ Treatment*matchingGroup + 
                    Treatment*playerid,data=exam),lmer.T)