Sometimes when working with small paired data-sets it is nice to see/show all the data in a structured form. For example when looking at pre-post comparisons, connected dots are a natural way to visualize which data-points belong together. In R this can be easily be combined with boxplots expressing the overall distribution of the data.  This also has the advantage of beeing more true to non-normal data that is not correctly represented by means +/- 95%CI. I have not come up against a good tutorial of how to do such a plot (although the right hand plot borrows heavily from this post on the excellent R-mailing list), so in the post you will find the code to generate such a graph in R.

Here comes the code (Update 05.12.2011 without umlauts):

#generatingsomedata
pre<-55+rnorm(20)
post<-pre+0.7+rnorm(20)

#Settinguptwoscreens
par(mfrow=c(1,2))

#FirstGraph
s<-seq(length(pre))
par(bty="l")
boxplot(pre,post,main="Rawdata",xlab="Time",ylab="Measure",names=c("pre","post"),col=c("lightblue","lightgreen"))
stripchart(list(pre,post),vertical=T,pch=16,method="jitter",cex=0.5,add=T)
segments(rep(0.95,length(pre))[s],pre[s],rep(2,length(pre))[s],post[s],col=1,lwd=0.5)
#Secondgraph
#Confidenceintervals eitherparametric (t.test) or non-parametric (wilcox.text)
#res<-t.test(post,prä,paired=T,conf.int=T)
res<-wilcox.test(post,pre,paired=T,conf.int=T)

stripchart(post-pre,vertical=T,pch=16,method="jitter",main="Difference",ylab="Difference:Post–Prä",xlab="Median+/-95%CI")
points(1,res$estimate,col="red",pch=16,cex=2)
arrows(1,res$conf.int[1],1,res$conf.int[2],col="red",code=3,lwd=3,angle=90)
abline(h=0,lty=2)#Zero-effectline

The world is flat F(1,18) = 39.200; p = .335 - or p < .01 or p <.001? - Check your stats!

A reviewers dream has come true. The new __statcheck__-package for [R](r-project.org) automagically checks the accurate __reporting__ of ...… Continue reading

Publication-lists-4-Your-Website

Published on June 19, 2015

Relaunch on Jekyll

Published on June 04, 2015