1

I am unsure how to provide sample data; my data is currently in a .csv file and is very large. I can provide additional information about the data.

I have used the following code to generate boxplots of the mean for my variable Pun with error bars of the standard error of the mean. However, I did not treat subjects as a random effect (each subject had three trials).

I understand how to fit the random effects model thanks to How to fit a random effects model with Subject as random in R? but I am not sure how I can account for that when I plot it. MS is a factor with 2 levels, Harm is a factor with 4 levels.

cdataPun <- ddply(Emotions1, c("MS.f","Harm.f"), summarise,
                  N=length(Pun),
                  mean=mean(Pun),
                  sd=sd(Pun),
                  se=sd/sqrt(N))

ggplot(cdataPun, aes(x=Harm.f, y=mean, fill=MS.f)) +
  geom_bar(position=position_dodge(), stat="identity", colour="black", size=.3) +
  geom_errorbar(aes(ymin=mean-se, ymax=mean+se), width=.2,
                position=position_dodge(.9))+
  xlab("Harm Level") +
  ylab("Punishment Rating") +
  scale_fill_hue(name="Mental State",
                 breaks=c("Blameless","Purposeful"),
                 labels=c("Blameless","Purposeful")) +
  ggtitle("Punishment Ratings by Harm and Mental State") +
  scale_y_discrete(breaks=0:10*1) +
  theme_bw()
Community
  • 1
  • 1
laharts
  • 13
  • 4
  • You can use the `effects` package to get the model estimates and plot those, possibly with some representation of the original data as well. It's hard to give you some example code without some data. If the data is large, try to give us a representative chunk, as well as the code for model. – Axeman Sep 29 '15 at 21:09
  • 1
    Thank you, the effects package was exactly what I needed and your recommendation led me to http://mindingthebrain.blogspot.com/2014/08/plotting-mixed-effects-model-results.html which was the code I was looking for. – laharts Sep 30 '15 at 16:37

0 Answers0