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(91.99,92.17,92.19,92.24,92.19,92.21,92.22,92.14,92.43,92.93,93.01,93.07,93.08,93.11,93.21,93.49,93.48,93.51,93.52,93.49,93.76,94.25,94.42,94.45,94.45,94.53,94.78,95.05,95.21,95.23,95.23,95.34,95.93,96.75,97.15,97.21,97.21,97.35,97.44,97.34,97.44,97.43,97.43,97.47,97.69,98.54,98.64,98.72,98.72,98.73,98.68,98.75,98.73,98.74,98.75,98.85,99.14,99.83,99.93,100,100,100.08,100.25,100.4,100.33,100.29,100.29,100.32,100.82,101.42,101.46,101.55,101.56,101.56,101.6,101.66,101.82,101.94,101.95,101.93,102.26,102.65,102.9,102.94,99.14,99.18,99.23,99.32,99.46,99.5,99.95,100.13,100.43,101.09,101.27,101.29,101.04,101.14,101.11,101.01,101.08,101.06,101.26,101.32,101.4,101.85,102.12,102.15) > 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,] 91.99 93.08 94.45 97.21 98.72 100.00 101.56 99.14 101.04 [2,] 92.17 93.11 94.53 97.35 98.73 100.08 101.56 99.18 101.14 [3,] 92.19 93.21 94.78 97.44 98.68 100.25 101.60 99.23 101.11 [4,] 92.24 93.49 95.05 97.34 98.75 100.40 101.66 99.32 101.01 [5,] 92.19 93.48 95.21 97.44 98.73 100.33 101.82 99.46 101.08 [6,] 92.21 93.51 95.23 97.43 98.74 100.29 101.94 99.50 101.06 [7,] 92.22 93.52 95.23 97.43 98.75 100.29 101.95 99.95 101.26 [8,] 92.14 93.49 95.34 97.47 98.85 100.32 101.93 100.13 101.32 [9,] 92.43 93.76 95.93 97.69 99.14 100.82 102.26 100.43 101.40 [10,] 92.93 94.25 96.75 98.54 99.83 101.42 102.65 101.09 101.85 [11,] 93.01 94.42 97.15 98.64 99.93 101.46 102.90 101.27 102.12 [12,] 93.07 94.45 97.21 98.72 100.00 101.55 102.94 101.29 102.15 > 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] 92.39917 93.64750 95.57167 97.72500 99.07083 100.60083 102.06417 [8] 99.99917 101.37833 > arr.sd [1] 0.3782365 0.4797371 0.9701062 0.5598945 0.5269890 0.5640190 0.5081599 [8] 0.8354798 0.4215951 > arr.range [1] 1.08 1.37 2.76 1.51 1.32 1.55 1.38 2.15 1.14 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 0.369724 0.002172 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -5.256 1.019 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 2.247619 -0.006764 > postscript(file="/var/wessaorg/rcomp/tmp/1154h1447876996.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/2yuzo1447876996.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/3q7sh1447876996.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/4pg0c1447876996.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/58fsf1447876996.tab") > > try(system("convert tmp/1154h1447876996.ps tmp/1154h1447876996.png",intern=TRUE)) character(0) > try(system("convert tmp/2yuzo1447876996.ps tmp/2yuzo1447876996.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.848 0.169 1.016