R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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(101.97,103.9,106.85,106.93,107.13,107.07,107.2,107.78,108,108.11,107.26,105.3,105.55,105.38,106.12,106.85,107.92,107.97,107.76,107.99,108.41,107.61,106.54,106.24,106.19,106.71,106.36,107.53,107.89,108,108.05,108.86,109.27,108.87,108.88,108.19,108.19,108.91,110.39,111.21,111.44,111.87,111.88,111.93,111.76,111.66,110.25,109.05,109.47,109.68,110.93,111.86,112.66,112.96,113.14,113.53,113.62,112.51,111,108.49,108.52,110.66,111.15,112.14,113.38,113.75,113.89,113.92,116.4,115.86,115.16,114.45,114.65,114.85,116.51,118.18,118.75,119.06,119.28,119.68,119.28,117.3,114.23,112.56,112.83,112.35,112.8,113.84,115.02,115.46,115,115.3,116.09,115.49,112.89,110.66) > 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] 96 > (np <- floor(n / par1)) [1] 8 > 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] [1,] 101.97 105.55 106.19 108.19 109.47 108.52 114.65 112.83 [2,] 103.90 105.38 106.71 108.91 109.68 110.66 114.85 112.35 [3,] 106.85 106.12 106.36 110.39 110.93 111.15 116.51 112.80 [4,] 106.93 106.85 107.53 111.21 111.86 112.14 118.18 113.84 [5,] 107.13 107.92 107.89 111.44 112.66 113.38 118.75 115.02 [6,] 107.07 107.97 108.00 111.87 112.96 113.75 119.06 115.46 [7,] 107.20 107.76 108.05 111.88 113.14 113.89 119.28 115.00 [8,] 107.78 107.99 108.86 111.93 113.53 113.92 119.68 115.30 [9,] 108.00 108.41 109.27 111.76 113.62 116.40 119.28 116.09 [10,] 108.11 107.61 108.87 111.66 112.51 115.86 117.30 115.49 [11,] 107.26 106.54 108.88 110.25 111.00 115.16 114.23 112.89 [12,] 105.30 106.24 108.19 109.05 108.49 114.45 112.56 110.66 > 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] 106.4583 107.0283 107.9000 110.7117 111.6542 113.2733 117.0275 113.9775 > arr.sd [1] 1.840883 1.044839 1.029793 1.336575 1.724552 2.289594 2.414544 1.662113 > arr.range [1] 6.14 3.03 3.08 3.74 5.13 7.88 7.12 5.43 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean -9.4412 0.1001 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -31.486 6.785 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean -28.773 0.306 > postscript(file="/var/wessaorg/rcomp/tmp/1tak91426175117.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/2d27x1426175117.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/3lt4u1426175117.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/490jc1426175117.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/5fv921426175117.tab") > > try(system("convert tmp/1tak91426175117.ps tmp/1tak91426175117.png",intern=TRUE)) character(0) > try(system("convert tmp/2d27x1426175117.ps tmp/2d27x1426175117.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.889 0.159 1.051