![[A picture of Oliver Kirchkamp]](../images/oliver5344.jpeg)
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 are
- The R Guide, Jason Owen (Easy to read, tries to explain R with the help of examples from basic statistics)
- Simple R, John Verzani (Tries to explain R with the help of examples from basic statistics)
- Einführung in R, Günther Sawitzki (In German. Rather compact introduction. The statistical part can be quite demanding)
- Econometrics in R, Grant V. Farnsworth (The introduction to R is rather compact and pragmatic. The econometric models go beyond what we are doing in this lecture)
- An Introduction to R, W. N. Venables und D. M. Smith (The focus is more on R as a programming language)
- The R language definition (Concentrates only on R as a programming language. A must to read if you write your own functions)
- A first entry into R eased through mice and menues is available through the R Commander.
- In the lecture I use the versatile editor Emacs with the ESS interface (ESS also helps with Stata, SAS, Splus, BUGS, and others). Users of MacOS-X will prefer the Emacs-Clone aquamacs.
- 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.
- Documentation for R is
provided via the build in help but also through the
R Homepage.
Useful are
- 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
pdftkor 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 saysummary(lm (effort ~ (Treatment=="red"),data=exam))
In the lecture I forgot to mention thatgeeglmneeds 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 forTreatmententirely. 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 thatanovais anticonservative and that one should better use a permutation test.hausman(lm(effort ~ Treatment*matchingGroup + Treatment*playerid,data=exam),lmer.T)
