R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" Copyright (C) 2015 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(98.85,98.86,98.86,98.89,98.85,98.85,98.85,98.96,98.99,99.21,99.29,99.32,99.32,99.17,99.13,99.12,99.23,99.25,99.25,99.36,99.43,99.57,99.64,99.68,99.68,99.52,99.69,99.7,99.85,99.94,99.94,99.93,100.19,100.57,100.76,100.86,100.86,100.39,100.61,100.67,100.81,100.86,100.86,100.98,101.03,101.37,101.64,101.68,101.68,101.25,101.24,101.11,101.08,101.09,101.09,101.62,101.66,101.96,102.04,102.02,102.02,101.51,101.62,101.83,102.06,102.14,102.14,102.59,102.92,103.31,103.54,103.58,103.58,102.83,102.86,103.03,103.2,103.28,103.28,103.79,103.92,104.26,104.41,104.45,99.92,99.18,99.18,99.35,99.62,99.67,99.72,100.08,100.39,100.77,101.03,101.07,101.29,101.1,101.2,101.15,101.24,101.16,100.81,101.02,101.15,101.06,101.17,101.22) > 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] 108 > (np <- floor(n / par1)) [1] 9 > 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] [1,] 98.85 99.32 99.68 100.86 101.68 102.02 103.58 99.92 101.29 [2,] 98.86 99.17 99.52 100.39 101.25 101.51 102.83 99.18 101.10 [3,] 98.86 99.13 99.69 100.61 101.24 101.62 102.86 99.18 101.20 [4,] 98.89 99.12 99.70 100.67 101.11 101.83 103.03 99.35 101.15 [5,] 98.85 99.23 99.85 100.81 101.08 102.06 103.20 99.62 101.24 [6,] 98.85 99.25 99.94 100.86 101.09 102.14 103.28 99.67 101.16 [7,] 98.85 99.25 99.94 100.86 101.09 102.14 103.28 99.72 100.81 [8,] 98.96 99.36 99.93 100.98 101.62 102.59 103.79 100.08 101.02 [9,] 98.99 99.43 100.19 101.03 101.66 102.92 103.92 100.39 101.15 [10,] 99.21 99.57 100.57 101.37 101.96 103.31 104.26 100.77 101.06 [11,] 99.29 99.64 100.76 101.64 102.04 103.54 104.41 101.03 101.17 [12,] 99.32 99.68 100.86 101.68 102.02 103.58 104.45 101.07 101.22 > 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] 98.98167 99.34583 100.05250 100.98000 101.48667 102.43833 103.57417 [8] 99.99833 101.13083 > arr.sd [1] 0.1832948 0.1946306 0.4470738 0.3969658 0.3859659 0.7342013 0.5858399 [8] 0.6784050 0.1258757 > arr.range [1] 0.47 0.56 1.34 1.29 0.96 2.07 1.62 1.89 0.48 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean -7.54816 0.07893 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -99.49 21.34 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean -20.7451 0.2174 > postscript(file="/var/wessaorg/rcomp/tmp/15ggw1452545030.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/2ewsp1452545030.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/3qezj1452545030.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/4grfk1452545030.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/5cqh01452545030.tab") > > try(system("convert tmp/15ggw1452545030.ps tmp/15ggw1452545030.png",intern=TRUE)) character(0) > try(system("convert tmp/2ewsp1452545030.ps tmp/2ewsp1452545030.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.825 0.155 0.990