Contrasts in R for two-way and three-way interactions

#1
I am new to using R and have just performed some mixed effect models which have significant 2-way and 3-way interactions. My question is now that I have a nicely constructed model, what next?

Basically, I would like to perform pairwise comparisons for all of my interactions. My fixed effects are treatment (2 levels), day (3 levels), and time (3 levels). I have no idea how to set up contrast variables within my data set and then actually perform the contrasts using R. I am used to the point-and-click methods in SPSS for doing this, so I am desperate to figure out how to do this in R so I can complete my analysis.

Any help?
 

Dason

Ambassador to the humans
#2
If you're looking for all pairwise comparisons you can use TukeyHSD. Otherwise there is always the "contrast" package.

If I'm not doing pairwise comparisons I usually just code in the matrix manipulations myself. Well... scratch that I have my own functions but I set up the contrast matrices myself.
 

trinker

ggplot2orBust
#3
I am new to using R and have just performed some mixed effect models which have significant 2-way and 3-way interactions. My question is now that I have a nicely constructed model, what next?
jmike when i was new to [R] I didn't know where to go for help. In case you don't know where to go for help either I wanted to let you know about Rseek ( a search engine just for [R]). Simply type rseek.org into the address bar. When I do this and then type in pairwise comparisons I get a ton of results (including some of the ideas Dason gives). I hope this helps. It has made searching and proficiency with [R] much quicker for me. By the way one of the search hits that seemed extremely pertinent to you is listed below:
http://www.r-bloggers.com/r-tutorial-series-anova-pairwise-comparison-methods/
 

Dason

Ambassador to the humans
#5
What's this Dason? Holding out on the Rcode, functions, thread.:shakehead
Ha. Well I didn't really think it counted. It's just the matrix manipulations you use to test a contrast in a linear model. I guess I could post it at some point.
 
#8
I have been trying to work this out, but am still struggling with this. The contrast packages seems to be the way to go, but I cannot figure it out.

My three factors are tx.f (2 levels) , Day.f (2 levels here) , and Time.f (3 levels). When I run my lme, I get my list of fixed effects (and I deleted the actual results from here just to keep it simple):

(Intercept)
tx.f2
Day.f2
Time.f2
Time.f3
tx.f2 : Day.f2
tx.f2 : Time.f2
tx.f2 : Time.f3
Day.f2 : Time.f2
Day.f2 : Time.f3
tx.f2 : Day.f2 : Time.f2
tx.f2 : Day.f2 : Time.f3

So, if I wish to do a contrasts between tx=1 and tx=2 for Day=2, Time=2, how would I do that? Or If I wanted to do a constrast between tx=1, Day=2, Time = 2 vs. tx=1, Day = 2, time =3? Or, if I only want to compare from a two way interaction (ie, Day=1 Time=2 vs. Day 1 =1 Time = 3).

I just don't understand the syntax I am supposed to put following the "list" argument in the command, and how I manipulate that for each planned contrast I want to look at... I just can't find a good example elsewhere. I have found a few threads with others asking for help on other forums, but the answers don't seem to be there. I am sure it will be obvious once I understand it, I am just struggling to get it right.

Thanks in advance!
 
#9
I figured out the problem. I needed quotes around my factor names. Everything is coded as a number, in my syntax, I simply listed an equal sign and then the numeric value. Instead, I needed quotes in front of the numeric value for each factor. That cleared everything up.