mysegplot<-function(stats,labs){ miny<-min(eval(parse(text=stats[2])))-.0025 maxy<-max(eval(parse(text=stats[3])))+.0025 ys<-seq(miny,maxy,(maxy-miny)/14) plot(1:15,ys,xlab="",ylab="",ylim=c(miny,maxy),type="n",axes=FALSE) nums<-seq(0,((3*length(stats)+4)-3),4) for (j in 1:length(stats)){ k<-0 for (i in (nums[j]+1):(nums[j]+3)){ k<-k+1 tmpstat<-eval(parse(text=stats[j])) points(i,tmpstat[4,k],type="p",pch=1,cex=.5) #Medians # segments(i-.25,tmpstat[3,k],i+.25,tmpstat[3,k]) #Mean Line segments(i,tmpstat[2,k],i,tmpstat[1,k]) #25% - 5% segments(i,tmpstat[5,k],i,tmpstat[6,k]) # 75% - 95% text(i,tmpstat[6,k]+.003,labels=k,cex=.66,offset=0) } } axis(1, at = seq(2,((3*length(stats))+3),4), labels = labs ,tick=FALSE,line=-2) axis(2) title(ylab="Standard Error") } par(mfrow=c(1,1),mar=c(0,4,0,0)+.1) #Split the Standard Errors for each variable by the design. CbyDesign<-split(SEConst,design) XbyDesign<-split(SEX,design) Z1byDesign<-split(SEZ1,design) Z2byDesign<-split(SEZ2,design) XZ1byDesign<-split(SEXZ1,design) XZ2byDesign<-split(SEXZ2,design) #Calculate summary statistics for each variable by design. sumC<-sapply(CbyDesign,FUN=function(x) c(quantile(x,c(.05,.25,.50)),mean(x),quantile(x,c(.75,.95)))) sumX<-sapply(XbyDesign,FUN=function(x) c(quantile(x,c(.05,.25,.50)),mean(x),quantile(x,c(.75,.95)))) sumZ1<-sapply(Z1byDesign,FUN=function(x) c(quantile(x,c(.05,.25,.50)),mean(x),quantile(x,c(.75,.95)))) sumZ2<-sapply(Z2byDesign,FUN=function(x) c(quantile(x,c(.05,.25,.50)),mean(x),quantile(x,c(.75,.95)))) sumXZ1<-sapply(XZ1byDesign,FUN=function(x) c(quantile(x,c(.05,.25,.50)),mean(x),quantile(x,c(.75,.95)))) sumXZ2<-sapply(XZ2byDesign,FUN=function(x) c(quantile(x,c(.05,.25,.50)),mean(x),quantile(x,c(.75,.95)))) #Make a list of the objects to be plotted. sumstuffsmall<-as.list(c("sumC","sumX","sumZ1","sumXZ1")) #Call the plotting function. mysegplot(stats=sumstuffsmall, labs=c("Constant","Micro","Macro","Cross-Level"))