R version 3.2.2 (2015-08-14) -- "Fire Safety" 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.41,98.94,99.09,100.45,101.99,102.35,102.69,102.6,102.62,102.73,102.74,103.45,103.9,103.45,103.5,103.33,103.56,103.58,103.86,103.77,103.73,104.21,104.55,104.5,104.66,104.99,104.99,105.62,106.52,106.1,106.73,106.63,106.72,106.5,107.12,106.84,107.25,108.19,108.21,107.98,109.12,109.79,109.69,109.69,109.24,108.55,106.47,107.27,105.95,108.55,110.81,111.54,110.38,106.67,106.45,105.44,105.37,103.72,106.57,108.54,110.36,106.64,103.45,101.36,101.9,100.86,100.37,100.16,99.5,99.52,99.2,99.35,99.37,99.85,99.76,100.07,99.77,99.93,99.16,99.4,99.81,99.67,99.37,99.49,99.28,99.33,99.19,98.11,99.12,99.06,97.41,98.45,100.33,103.18,103.06,103.48,102.8,103.92,103.9,103.96,103.62,103.83,104.09,104.07,103.22,104.01,104.01,104.24) > 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.41 103.90 104.66 107.25 105.95 110.36 99.37 99.28 102.80 [2,] 98.94 103.45 104.99 108.19 108.55 106.64 99.85 99.33 103.92 [3,] 99.09 103.50 104.99 108.21 110.81 103.45 99.76 99.19 103.90 [4,] 100.45 103.33 105.62 107.98 111.54 101.36 100.07 98.11 103.96 [5,] 101.99 103.56 106.52 109.12 110.38 101.90 99.77 99.12 103.62 [6,] 102.35 103.58 106.10 109.79 106.67 100.86 99.93 99.06 103.83 [7,] 102.69 103.86 106.73 109.69 106.45 100.37 99.16 97.41 104.09 [8,] 102.60 103.77 106.63 109.69 105.44 100.16 99.40 98.45 104.07 [9,] 102.62 103.73 106.72 109.24 105.37 99.50 99.81 100.33 103.22 [10,] 102.73 104.21 106.50 108.55 103.72 99.52 99.67 103.18 104.01 [11,] 102.74 104.55 107.12 106.47 106.57 99.20 99.37 103.06 104.01 [12,] 103.45 104.50 106.84 107.27 108.54 99.35 99.49 103.48 104.24 > 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] 101.5050 103.8283 106.1183 108.4542 107.4992 101.8892 99.6375 100.0000 [9] 103.8058 > arr.sd [1] 1.7763113 0.4011083 0.8394136 1.0893072 2.4473342 3.4165226 0.2747602 [8] 2.0815073 0.4109956 > arr.range [1] 5.04 1.22 2.46 3.32 7.82 11.16 0.91 6.07 1.44 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 3.33808 -0.01855 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -13.112 2.831 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 8.48238 -0.03956 > postscript(file="/var/wessaorg/rcomp/tmp/1jtaq1447786236.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/2lizv1447786236.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/3z3g21447786236.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/4feff1447786236.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/53w8c1447786236.tab") > > try(system("convert tmp/1jtaq1447786236.ps tmp/1jtaq1447786236.png",intern=TRUE)) character(0) > try(system("convert tmp/2lizv1447786236.ps tmp/2lizv1447786236.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.919 0.162 1.083