Thijs Muizelaar
2010-Oct-17 20:03 UTC
[R] unbalanced repeated measurements Anova with mixed effects
Dear R-list members, I've been struggling with the proper setup for analysing my data. I've performed a route choice experiment, in which participants had to make a choice at each junction for the next road. During the experiment they received traffic information, but also encountered two different accidents. They also made trips without accidents. What I'm interested in is to see if the traffic information influenced their route choice, regarding their total travel time, the delay and the number of junctions they passed. These are thus three dependent variables. The independent variables are the type of traffic information and the accident situation, and personal characteristics such as age, gender and amount of kilometers driven each year. In order to simplify this, I've seperated each accident in a data frame (because the trips without accidents, don't have all the different types of traffic information). As far as my limited statical knowledge goes, this implies I have a mixed repeated measurements experiment. To be able to answer the hypotheses that traffic information influences traveltime, delay and number of junctions, I can do an Anova. However, the datasets are also unbalanced, because not all trips lead to the right destination. I've found that the car package presents the proper tools to do this, but I'm not sure if the following model will give the results I want to have. Can anyone help me with that? I've put the data in a wide format, where traveltime.1 stands for the measured traveltime with traffic information 1, etc. event1.mod.car<-lm(cbind("traveltime.1","traveltime.2","traveltime.3")~age*gender*kmyear, data=event1.wide) event1.aov.car<-Anova(event1.mod.car, idata=idata, idesign=~guidanceID) Can I also use the aov function? But because of the unbalanced data, this will probably not provide the right results. Is that right? event1.aov<-aov(traveltime~guidanceID*gender*age*kmyear + Error(userID/guidanceID), data=event1) Thanks in advance! Thijs Muizelaar PhD student University of Twente
Tal Galili
2010-Oct-17 20:21 UTC
[R] unbalanced repeated measurements Anova with mixed effects
Hello Thijs, I think that as you wrote, the aov wouldn't work for you here (due to the unbalanced design). I'd recommend you to have a look at the {ez<http://cran.r-project.org/web/packages/ez/index.html> } package, which offers a nice wrapping of the car Anova functions. I've listed a bunch of tutorials on the topic here: http://www.r-statistics.com/2010/04/repeated-measures-anova-with-r-tutorials/ That might prove useful for you. Best, Tal <http://www.r-statistics.com/2010/04/repeated-measures-anova-with-r-tutorials/> ----------------Contact Details:------------------------------------------------------- Contact me: Tal.Galili@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) ---------------------------------------------------------------------------------------------- On Sun, Oct 17, 2010 at 10:03 PM, Thijs Muizelaar <thijs.muizelaar@xs4all.nl> wrote:> Dear R-list members, > > I've been struggling with the proper setup for analysing my data. I've > performed a route choice experiment, in which participants had to make a > choice at each junction for the next road. During the experiment they > received traffic information, but also encountered two different accidents. > They also made trips without accidents. > > What I'm interested in is to see if the traffic information influenced > their route choice, regarding their total travel time, the delay and the > number of junctions they passed. These are thus three dependent variables. > > The independent variables are the type of traffic information and the > accident situation, and personal characteristics such as age, gender and > amount of kilometers driven each year. In order to simplify this, I've > seperated each accident in a data frame (because the trips without > accidents, don't have all the different types of traffic information). > > As far as my limited statical knowledge goes, this implies I have a mixed > repeated measurements experiment. To be able to answer the hypotheses that > traffic information influences traveltime, delay and number of junctions, I > can do an Anova. However, the datasets are also unbalanced, because not all > trips lead to the right destination. > > I've found that the car package presents the proper tools to do this, but > I'm not sure if the following model will give the results I want to have. > Can anyone help me with that? > > I've put the data in a wide format, where traveltime.1 stands for the > measured traveltime with traffic information 1, etc. > > event1.mod.car<-lm(cbind("traveltime.1","traveltime.2","traveltime.3")~age*gender*kmyear, > data=event1.wide) > event1.aov.car<-Anova(event1.mod.car, idata=idata, idesign=~guidanceID) > > Can I also use the aov function? But because of the unbalanced data, this > will probably not provide the right results. Is that right? > > event1.aov<-aov(traveltime~guidanceID*gender*age*kmyear + > Error(userID/guidanceID), data=event1) > > Thanks in advance! > > > Thijs Muizelaar > PhD student University of Twente > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]