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(78.25,77.24,76.68,76.29,76.1,75.77,75.6,75.57,75.89,76.04,76.89,77,79.09,80.84,81.82,82.12,81.01,82.22,81.97,82.42,82.77,82.46,83.35,84.27,87.34,91.03,93.52,94.24,94.92,95.49,96.55,98.07,102.87,104.12,103.49,103.31,103.92,103.69,103.41,102.83,103,103.42,102.57,102.72,102.22,102.32,102.48,101.56,101.02,101.41,100.74,99.76,99.76,99.17,99.11,99.69,99.4,99.79,99.72,98.74,98.26,97.31,96.73,96.18,95.92,96.13,95.64,94.52,94.31,96.05,96.17,95.14,95.37,96.5,96.79,96.23,96,95.21,94.77,96.84,99.06,100.36,100.09,100.03,100.49,101,102.11,101.59,100.81,100.86,99.57,100.21,99.68,98.38,97.93,97.37,99.08,99.15,99.44,99.48,99.62,98.95,99.42,99.84,99.27,99.16,99.04,99.62) > 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,] 78.25 79.09 87.34 103.92 101.02 98.26 95.37 100.49 99.08 [2,] 77.24 80.84 91.03 103.69 101.41 97.31 96.50 101.00 99.15 [3,] 76.68 81.82 93.52 103.41 100.74 96.73 96.79 102.11 99.44 [4,] 76.29 82.12 94.24 102.83 99.76 96.18 96.23 101.59 99.48 [5,] 76.10 81.01 94.92 103.00 99.76 95.92 96.00 100.81 99.62 [6,] 75.77 82.22 95.49 103.42 99.17 96.13 95.21 100.86 98.95 [7,] 75.60 81.97 96.55 102.57 99.11 95.64 94.77 99.57 99.42 [8,] 75.57 82.42 98.07 102.72 99.69 94.52 96.84 100.21 99.84 [9,] 75.89 82.77 102.87 102.22 99.40 94.31 99.06 99.68 99.27 [10,] 76.04 82.46 104.12 102.32 99.79 96.05 100.36 98.38 99.16 [11,] 76.89 83.35 103.49 102.48 99.72 96.17 100.09 97.93 99.04 [12,] 77.00 84.27 103.31 101.56 98.74 95.14 100.03 97.37 99.62 > 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] 76.44333 82.02833 97.07917 102.84500 99.85917 96.03000 97.27083 [8] 100.00000 99.33917 > arr.sd [1] 0.7978190 1.3085928 5.4242778 0.6799532 0.8034297 1.1015939 2.0478035 [8] 1.4701144 0.2740092 > arr.range [1] 2.68 5.18 16.78 2.36 2.67 3.95 5.59 4.74 0.89 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 0.17794 0.01446 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) 0.43809 -0.07112 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 2.91360 0.02188 > postscript(file="/var/wessaorg/rcomp/tmp/1w23z1448046043.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/2d4b61448046043.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/3xj3f1448046043.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/428em1448046043.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/5022g1448046043.tab") > > try(system("convert tmp/1w23z1448046043.ps tmp/1w23z1448046043.png",intern=TRUE)) character(0) > try(system("convert tmp/2d4b61448046043.ps tmp/2d4b61448046043.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.812 0.145 0.968