
Table of contents
Table of contents

How we can model this?
As we are not particularly interested in the effects of mouse, brain sample and photo, we used the random effects to describe them. The effects of mouse and treatment type are directly interesting so we used the fixed effects to describe them. All together we get mixed models, that is, the lmer function from the lme4 package.mmodel = lmer(spine ~ type*treatment + (1|animal:type) + (1|animal:type:sample) + (1|animal:type:sample:photo), data=spines)I was looking for a function for post hoc testing and I found the lsmeans function in the package bearing the same name (functionality borrowed from the LSMEANS SASa procedure). The package allows for testing many various contrasts. For example, the following command compares all pairs using Tukey’s post hoc procedure.
ms6 = lsmeans(mmodel, pairwise~ type*treatment, adjust="tukey")The only disadvantage of that package is lack of function for graphical presentation of the post hoc test’s results. On the other hand in SAS one can use diffograms to graphically present post hoc tests. I felt uneasy that I could not find them in R so I wrote a diffogram function myself (see the package DendriticSpineR). Below you can see an example diffogram.
diffogram(ms6)
