R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- c(1.6,2,2.6,3,2.6,2.9,2.5,2.4,1.5,1.1,0.6,0.9,1.1,1.5,1.7,1.2,0.4,-0.7,-1.4,-1.6,-1.2,-0.4,-0.2,-0.3,-0.5,0,-0.5,0.2,0.7,1.6,2.6,3.3,3.3,3.2,3.5,3.9,4.5,4.6,6.6,7.1,8.9,8.8,8.5,7.6,7.5,7.5,6.1,6.3,8.4,7.1,5.6,4.2,2.1,1.2,0.9,1.4,1.7,1.7,1.9,1.3,-0.7,0.3,0.8,0.9,1.1,2.5,2.7,3.3,4.2,3.8,3.8,3.2,2.9,1.9,1.7,1.6,1.7,1.2,0.7,-0.2,-1.5,-1.2,-1,0,-0.6,0.7,1.3,0.8,1,0.5,0.3,1,1,1.1,1.5,1.5,2,1.7,0.6,1.2,1.5,2.1,3.2,3.9,4.6,4.2,4.4,3.7,3.7,2.8,2.9,3.9,3.1,3,2.8,2.4,2.1,3.1,3,3.1,3.3,3.3,3.8,3.1,3.9,4,4.4,3.7,3.6,3.4,2.8,2.8,2.6,3.3,2.4,1.6,0.7,0,-1.1,-1.2,-1.3,-1.6,-1.3,-1.6,-1.1,-1,0.3,1.2,0.7,1.1,2.1,2.5,2.3,2.3,2.6,3.2,2.2,2.7,2.2,1.4,2.4,2,1.3,1.1,1.4,1.8,1.9,1.6) > par1 = '12' > par1 <- '12' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P. (2012), Standard Deviation-Mean Plot (v1.0.6) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_smp.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > # > par1 <- as.numeric(par1) > (n <- length(x)) [1] 168 > (np <- floor(n / par1)) [1] 14 > arr <- array(NA,dim=c(par1,np)) > j <- 0 > k <- 1 > for (i in 1:(np*par1)) + { + j = j + 1 + arr[j,k] <- x[i] + if (j == par1) { + j = 0 + k=k+1 + } + } > arr [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [1,] 1.6 1.1 -0.5 4.5 8.4 -0.7 2.9 -0.6 2.0 3.7 3.3 2.6 -1.1 [2,] 2.0 1.5 0.0 4.6 7.1 0.3 1.9 0.7 1.7 2.8 3.3 3.3 -1.0 [3,] 2.6 1.7 -0.5 6.6 5.6 0.8 1.7 1.3 0.6 2.9 3.8 2.4 0.3 [4,] 3.0 1.2 0.2 7.1 4.2 0.9 1.6 0.8 1.2 3.9 3.1 1.6 1.2 [5,] 2.6 0.4 0.7 8.9 2.1 1.1 1.7 1.0 1.5 3.1 3.9 0.7 0.7 [6,] 2.9 -0.7 1.6 8.8 1.2 2.5 1.2 0.5 2.1 3.0 4.0 0.0 1.1 [7,] 2.5 -1.4 2.6 8.5 0.9 2.7 0.7 0.3 3.2 2.8 4.4 -1.1 2.1 [8,] 2.4 -1.6 3.3 7.6 1.4 3.3 -0.2 1.0 3.9 2.4 3.7 -1.2 2.5 [9,] 1.5 -1.2 3.3 7.5 1.7 4.2 -1.5 1.0 4.6 2.1 3.6 -1.3 2.3 [10,] 1.1 -0.4 3.2 7.5 1.7 3.8 -1.2 1.1 4.2 3.1 3.4 -1.6 2.3 [11,] 0.6 -0.2 3.5 6.1 1.9 3.8 -1.0 1.5 4.4 3.0 2.8 -1.3 2.6 [12,] 0.9 -0.3 3.9 6.3 1.3 3.2 0.0 1.5 3.7 3.1 2.8 -1.6 3.2 [,14] [1,] 2.2 [2,] 2.7 [3,] 2.2 [4,] 1.4 [5,] 2.4 [6,] 2.0 [7,] 1.3 [8,] 1.1 [9,] 1.4 [10,] 1.8 [11,] 1.9 [12,] 1.6 > arr.mean <- array(NA,dim=np) > arr.sd <- array(NA,dim=np) > arr.range <- array(NA,dim=np) > for (j in 1:np) + { + arr.mean[j] <- mean(arr[,j],na.rm=TRUE) + arr.sd[j] <- sd(arr[,j],na.rm=TRUE) + arr.range[j] <- max(arr[,j],na.rm=TRUE) - min(arr[,j],na.rm=TRUE) + } > arr.mean [1] 1.975000000 0.008333333 1.775000000 7.000000000 3.125000000 2.158333333 [7] 0.650000000 0.841666667 2.758333333 2.991666667 3.508333333 0.208333333 [13] 1.350000000 1.833333333 > arr.sd [1] 0.8158933 1.1555859 1.7062053 1.4597634 2.5669667 1.6104535 1.4126056 [8] 0.5822501 1.3931379 0.4851585 0.4851585 1.8362305 1.4080935 0.4886593 > arr.range [1] 2.4 3.3 4.4 4.4 7.5 4.9 4.4 2.1 4.0 1.8 1.6 4.9 4.3 1.6 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 1.2209 0.0104 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) 0.09152 -0.03505 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 3.54975 0.06306 > postscript(file="/var/wessaorg/rcomp/tmp/18cwd1355323411.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(arr.mean,arr.sd,main='Standard Deviation-Mean Plot',xlab='mean',ylab='standard deviation') > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/2oofs1355323411.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(arr.mean,arr.range,main='Range-Mean Plot',xlab='mean',ylab='range') > dev.off() null device 1 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Standard Deviation-Mean Plot',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Section',header=TRUE) > a<-table.element(a,'Mean',header=TRUE) > a<-table.element(a,'Standard Deviation',header=TRUE) > a<-table.element(a,'Range',header=TRUE) > a<-table.row.end(a) > for (j in 1:np) { + a<-table.row.start(a) + a<-table.element(a,j,header=TRUE) + a<-table.element(a,arr.mean[j]) + a<-table.element(a,arr.sd[j] ) + a<-table.element(a,arr.range[j] ) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/3dwoh1355323411.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Regression: S.E.(k) = alpha + beta * Mean(k)',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'alpha',header=TRUE) > a<-table.element(a,lm1$coefficients[[1]]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'beta',header=TRUE) > a<-table.element(a,lm1$coefficients[[2]]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'S.D.',header=TRUE) > a<-table.element(a,summary(lm1)$coefficients[2,2]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'T-STAT',header=TRUE) > a<-table.element(a,summary(lm1)$coefficients[2,3]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'p-value',header=TRUE) > a<-table.element(a,summary(lm1)$coefficients[2,4]) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/4gj7u1355323411.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Regression: ln S.E.(k) = alpha + beta * ln Mean(k)',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'alpha',header=TRUE) > a<-table.element(a,lnlm1$coefficients[[1]]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'beta',header=TRUE) > a<-table.element(a,lnlm1$coefficients[[2]]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'S.D.',header=TRUE) > a<-table.element(a,summary(lnlm1)$coefficients[2,2]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'T-STAT',header=TRUE) > a<-table.element(a,summary(lnlm1)$coefficients[2,3]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'p-value',header=TRUE) > a<-table.element(a,summary(lnlm1)$coefficients[2,4]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Lambda',header=TRUE) > a<-table.element(a,1-lnlm1$coefficients[[2]]) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/5khme1355323411.tab") > > try(system("convert tmp/18cwd1355323411.ps tmp/18cwd1355323411.png",intern=TRUE)) character(0) > try(system("convert tmp/2oofs1355323411.ps tmp/2oofs1355323411.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.388 0.221 1.591