![]() ![]() The steps here are for explanation purposes only they are not necessary for making the error bars. This section explains how the within-subjects error bar values are calculated. See the section below on normed means for more information. The value and value_norm columns represent the un-normed and normed means. 1, aes ( ymin = value - ci, ymax = value + ci )) + geom_point ( shape = 21, size = 3, fill = "white" ) + ylim ( 40, 60 ) Ggplot ( dfwc, aes ( x = condition, y = value, group = 1 )) + geom_line () + geom_errorbar ( width =. Library ( ggplot2 ) # Make the graph with the 95% confidence interval Here is a data set (from Morey 2008) with one within-subjects variable: pre/post-test.ĭfwc condition N value value_norm sd se ci See these papers for a more detailed treatment of the issues involved in error bars with within-subjects variables. The method below is from Morey (2008), which is a correction to Cousineau (2005), which in turn is meant to be a simpler method of that in Loftus and Masson (1994). However, when there are within-subjects variables (repeated measures), plotting the standard error or regular confidence intervals may be misleading for making inferences about differences between conditions. When all variables are between-subjects, it is straightforward to plot standard error or confidence intervals. 9 )) + xlab ( "Dose (mg)" ) + ylab ( "Tooth length" ) + scale_fill_hue ( name = "Supplement type", # Legend label, use darker colorsīreaks = c ( "OJ", "VC" ), labels = c ( "Orange juice", "Ascorbic acid" )) + ggtitle ( "The Effect of Vitamin C on\nTooth Growth in Guinea Pigs" ) + scale_y_continuous ( breaks = 0 : 20 * 4 ) + theme_bw () Geom_errorbar ( aes ( ymin = len - se, ymax = len + se ), size =. Ggplot ( tgc2, aes ( x = dose, y = len, fill = supp )) + geom_bar ( position = position_dodge (), stat = "identity", colour = "black", # Use black outlines, The points are drawn last so that the white fill goes on top of the lines and error bars. 1, position = pd ) + geom_line ( position = pd ) + geom_point ( position = pd, size = 3 )Ī finished graph with error bars representing the standard error of the mean might look like this. Ggplot ( tgc, aes ( x = dose, y = len, colour = supp, group = supp )) + geom_errorbar ( aes ( ymin = len - ci, ymax = len + ci ), colour = "black", width =. 1, position = pd ) + geom_line ( position = pd ) + geom_point ( position = pd ) # Black error bars - notice the mapping of 'group=supp' - without it, the error Ggplot ( tgc, aes ( x = dose, y = len, colour = supp )) + geom_errorbar ( aes ( ymin = len - ci, ymax = len + ci ), width =. 1, position = pd ) + geom_line ( position = pd ) + geom_point ( position = pd ) # Use 95% confidence interval instead of SEM Ggplot ( tgc, aes ( x = dose, y = len, colour = supp )) + geom_errorbar ( aes ( ymin = len - se, ymax = len + se ), width =. Pd <- position_dodge ( 0.1 ) # move them. 1 ) + geom_line () + geom_point () # The errorbars overlapped, so use position_dodge to move them horizontally ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |