R version 3.3.1 (2016-06-21) -- "Bug in Your Hair" 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(7175,7048.75,6922.5,6670,9225,9098.75,7175,5897.5,6023.75,6023.75,6150,6416.25,5645,4872.5,4240,4240,6670,6922.5,4998.75,2822.5,3973.75,3973.75,4872.5,5391.25,5265,3973.75,4620,4366.25,6542.5,6023.75,3973.75,2442.5,3847.5,4240,4620,5125,4100,3215,3595,3721.25,7048.75,7048.75,5125,4872.5,5645,5265,6290,7567.5,7821.25,6023.75,5517.5,4998.75,8466.25,8720,8073.75,8720,8592.5,7567.5,8720,9997.5,10516.25,8972.5,7947.5,8720,12047.5,13072.5,12820,13325,13198.75,11921.25,14097.5,14616.25,15375,13072.5,12173.75,13198.75,15641.25,17817.5,17298.75,17298.75,17552.5,16666.25,18970,18970,18577.5,16400,16792.5,17046.25,18716.25,20892.5,19348.75,20121.25,19475,19096.25,22045,21398.75,20500,19222.5,20500,21146.25,21917.5,22942.5,21917.5,22550,21778.75,21652.5,24853.75,25120,24095,22297.5,23828.75,24473.75,25246.25,26397.5,25246.25,26145,25752.5,24347.5,27296.25,27296.25) > 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] [1,] 7175.00 5645.00 5265.00 4100.00 7821.25 10516.25 15375.00 18577.50 [2,] 7048.75 4872.50 3973.75 3215.00 6023.75 8972.50 13072.50 16400.00 [3,] 6922.50 4240.00 4620.00 3595.00 5517.50 7947.50 12173.75 16792.50 [4,] 6670.00 4240.00 4366.25 3721.25 4998.75 8720.00 13198.75 17046.25 [5,] 9225.00 6670.00 6542.50 7048.75 8466.25 12047.50 15641.25 18716.25 [6,] 9098.75 6922.50 6023.75 7048.75 8720.00 13072.50 17817.50 20892.50 [7,] 7175.00 4998.75 3973.75 5125.00 8073.75 12820.00 17298.75 19348.75 [8,] 5897.50 2822.50 2442.50 4872.50 8720.00 13325.00 17298.75 20121.25 [9,] 6023.75 3973.75 3847.50 5645.00 8592.50 13198.75 17552.50 19475.00 [10,] 6023.75 3973.75 4240.00 5265.00 7567.50 11921.25 16666.25 19096.25 [11,] 6150.00 4872.50 4620.00 6290.00 8720.00 14097.50 18970.00 22045.00 [12,] 6416.25 5391.25 5125.00 7567.50 9997.50 14616.25 18970.00 21398.75 [,9] [,10] [1,] 20500.00 24095.00 [2,] 19222.50 22297.50 [3,] 20500.00 23828.75 [4,] 21146.25 24473.75 [5,] 21917.50 25246.25 [6,] 22942.50 26397.50 [7,] 21917.50 25246.25 [8,] 22550.00 26145.00 [9,] 21778.75 25752.50 [10,] 21652.50 24347.50 [11,] 24853.75 27296.25 [12,] 25120.00 27296.25 > 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] 6985.521 4885.208 4586.667 5291.146 7768.229 11771.250 16169.583 [8] 19159.167 22008.438 25201.875 > arr.sd [1] 1116.663 1165.078 1074.776 1469.610 1500.586 2219.511 2304.234 1799.659 [9] 1710.793 1483.396 > arr.range [1] 3327.50 4100.00 4100.00 4352.50 4998.75 6668.75 6796.25 5645.00 5897.50 [10] 4998.75 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 1247.6333 0.0272 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) 4.8622 0.2678 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 4.021e+03 8.624e-02 > postscript(file="/var/wessaorg/rcomp/tmp/1fsvv1470866443.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/2jfsb1470866443.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/3m8l51470866443.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/4s69k1470866443.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/5hygh1470866443.tab") > > try(system("convert tmp/1fsvv1470866443.ps tmp/1fsvv1470866443.png",intern=TRUE)) character(0) > try(system("convert tmp/2jfsb1470866443.ps tmp/2jfsb1470866443.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.862 0.102 0.967