R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch" Copyright (C) 2016 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(94.46,96.91,101.92,104.53,105.85,106.39,106.08,106.42,106.51,106.59,105.71,104.41,103.04,100.99,100.93,99.31,99.79,99.57,99.11,98.96,97.72,99.35,98.15,97.64,97.49,97.94,98.03,98.05,97.54,98.71,99.33,99.16,98.41,98.43,97.02,97.89,97.92,97.37,97.42,96.12,96.72,96.64,95.28,95.3,95.02,95.57,94.78,95.27,96.14,96.16,95.08,94.39,94.15,94.58,94.16,95.02,94.86,94.49,94.81,94.16,94.83,96.02,95.97,95.88,95.97,97.55,97.49,98.4,98.2,97.16,96.96,96.37,96.34,96.86,96.32,95.44,92.85,92.56,91.74,92.44,93.19,92.62,94.04,93.8,96.73,98.99,100.38,101.07,99.92,101.78,100.91,100.49,101.17,100.25,98.94,99.4,100.02,99.91,99.22,98.84,98.42,97.59,97.07,96.59,95.96,94.22,94.48,93.14,93.73,94.24,98.52,99.09,99.84,99.13,100.88,100.83,101.6,101.8,102.77,103.14) > 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] 120 > (np <- floor(n / par1)) [1] 10 > 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] [1,] 94.46 103.04 97.49 97.92 96.14 94.83 96.34 96.73 100.02 93.73 [2,] 96.91 100.99 97.94 97.37 96.16 96.02 96.86 98.99 99.91 94.24 [3,] 101.92 100.93 98.03 97.42 95.08 95.97 96.32 100.38 99.22 98.52 [4,] 104.53 99.31 98.05 96.12 94.39 95.88 95.44 101.07 98.84 99.09 [5,] 105.85 99.79 97.54 96.72 94.15 95.97 92.85 99.92 98.42 99.84 [6,] 106.39 99.57 98.71 96.64 94.58 97.55 92.56 101.78 97.59 99.13 [7,] 106.08 99.11 99.33 95.28 94.16 97.49 91.74 100.91 97.07 100.88 [8,] 106.42 98.96 99.16 95.30 95.02 98.40 92.44 100.49 96.59 100.83 [9,] 106.51 97.72 98.41 95.02 94.86 98.20 93.19 101.17 95.96 101.60 [10,] 106.59 99.35 98.43 95.57 94.49 97.16 92.62 100.25 94.22 101.80 [11,] 105.71 98.15 97.02 94.78 94.81 96.96 94.04 98.94 94.48 102.77 [12,] 104.41 97.64 97.89 95.27 94.16 96.37 93.80 99.40 93.14 103.14 > 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] 103.81500 99.54667 98.16667 96.11750 94.83333 96.73333 94.01667 [8] 100.00250 97.12167 99.63083 > arr.sd [1] 4.0552334 1.5318517 0.6802050 1.0673427 0.6952218 1.0685107 1.7747539 [8] 1.3537901 2.3026145 3.0068390 > arr.range [1] 12.13 5.40 2.31 3.14 2.01 3.57 5.12 5.05 6.88 9.41 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean -23.232 0.255 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -54.02 11.87 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean -75.2689 0.8242 > postscript(file="/var/wessaorg/rcomp/tmp/11gso1483956471.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/2h9rh1483956471.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/3dky11483956471.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/42luv1483956471.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/5x19y1483956471.tab") > > try(system("convert tmp/11gso1483956471.ps tmp/11gso1483956471.png",intern=TRUE)) character(0) > try(system("convert tmp/2h9rh1483956471.ps tmp/2h9rh1483956471.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.762 0.085 0.856