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(71.59,71.65,71.47,71.82,71.76,71.88,73.31,73.22,72.74,72.95,73.71,74.45,76.54,77.41,76.87,76.51,75.66,75.09,75.16,75,75.05,74.78,75.43,75.61,77.12,83.09,86.09,87.64,88.29,89.3,89.99,90.43,91.03,91.4,92.19,92.45,92.42,90.2,88.23,84.91,82.92,81.8,81.7,83.22,82.7,82.83,83.66,84.28,84.37,86.49,87.62,88.59,89.74,89.73,89.14,88.37,88.65,89.16,89.56,89.37,89.67,93.04,94.4,95.5,101.66,102.86,102.48,102.02,101.83,101.3,101.29,100.53,100.45,101.88,101.95,102.18,100.95,100.52,100.39,99.61,99.43,99.34,100.73,102.14,102.22,101.14,100.91,101.62,100,99.92,100.07,98.48,98.3,98.86,98.96,99.52,99.06,100.47,100.24,86.43,85.14,85.41,86.13,86.19,86.29,87.55,87.87,88.37) > 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,] 71.59 76.54 77.12 92.42 84.37 89.67 100.45 102.22 99.06 [2,] 71.65 77.41 83.09 90.20 86.49 93.04 101.88 101.14 100.47 [3,] 71.47 76.87 86.09 88.23 87.62 94.40 101.95 100.91 100.24 [4,] 71.82 76.51 87.64 84.91 88.59 95.50 102.18 101.62 86.43 [5,] 71.76 75.66 88.29 82.92 89.74 101.66 100.95 100.00 85.14 [6,] 71.88 75.09 89.30 81.80 89.73 102.86 100.52 99.92 85.41 [7,] 73.31 75.16 89.99 81.70 89.14 102.48 100.39 100.07 86.13 [8,] 73.22 75.00 90.43 83.22 88.37 102.02 99.61 98.48 86.19 [9,] 72.74 75.05 91.03 82.70 88.65 101.83 99.43 98.30 86.29 [10,] 72.95 74.78 91.40 82.83 89.16 101.30 99.34 98.86 87.55 [11,] 73.71 75.43 92.19 83.66 89.56 101.29 100.73 98.96 87.87 [12,] 74.45 75.61 92.45 84.28 89.37 100.53 102.14 99.52 88.37 > 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] 72.54583 75.75917 88.25167 84.90583 88.39917 98.88167 100.79750 [8] 100.00000 89.92917 > arr.sd [1] 0.9854345 0.8590635 4.4234783 3.4820147 1.5832387 4.4711435 1.0448934 [8] 1.2614494 6.1080267 > arr.range [1] 2.98 2.63 15.33 10.72 5.37 13.19 2.84 3.92 15.33 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean -0.99019 0.04144 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -8.013 1.952 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean -1.8035 0.1108 > postscript(file="/var/wessaorg/rcomp/tmp/1wtou1447870806.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/2q2d21447870806.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/39j0r1447870806.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/4q8to1447870806.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/5r4ar1447870806.tab") > > try(system("convert tmp/1wtou1447870806.ps tmp/1wtou1447870806.png",intern=TRUE)) character(0) > try(system("convert tmp/2q2d21447870806.ps tmp/2q2d21447870806.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.892 0.142 1.038