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(76.93,79.32,79.35,80.94,80.13,81.38,81.1,81.53,80.46,79.71,78.66,79.96,80.64,81.8,81.06,81.67,79.72,81.28,81.36,85.26,90,93,95.62,102.15,105.73,109.79,113.77,114.3,114.76,113.69,113.88,114.47,112.57,114.43,112.7,113.48,113.05,112.22,111.44,111.67,111.91,111.7,104.26,101.13,98.55,97.06,96.22,95.15,94.54,94.29,93.98,93.76,94.16,93.83,93.97,94.19,94.14,94.24,94.27,94.21,93.45,95.84,98.59,97,96.45,96.48,96.1,95.49,95.85,95.85,98.52,101.77,101.2,102.85,102.98,102.87,100.48,97.59,97.55,99.06,100.43,102.93,104.22,105.26,105.44,106.97,105.82,104.4,102.03,100.17,98.01,96.49,95.63,95.4,94.97,94.68,95.87,94.99,94.65,94.35,94.1,94.21,95.2,95.55,95.68,95.27,95.3,95.93) > 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,] 76.93 80.64 105.73 113.05 94.54 93.45 101.20 105.44 95.87 [2,] 79.32 81.80 109.79 112.22 94.29 95.84 102.85 106.97 94.99 [3,] 79.35 81.06 113.77 111.44 93.98 98.59 102.98 105.82 94.65 [4,] 80.94 81.67 114.30 111.67 93.76 97.00 102.87 104.40 94.35 [5,] 80.13 79.72 114.76 111.91 94.16 96.45 100.48 102.03 94.10 [6,] 81.38 81.28 113.69 111.70 93.83 96.48 97.59 100.17 94.21 [7,] 81.10 81.36 113.88 104.26 93.97 96.10 97.55 98.01 95.20 [8,] 81.53 85.26 114.47 101.13 94.19 95.49 99.06 96.49 95.55 [9,] 80.46 90.00 112.57 98.55 94.14 95.85 100.43 95.63 95.68 [10,] 79.71 93.00 114.43 97.06 94.24 95.85 102.93 95.40 95.27 [11,] 78.66 95.62 112.70 96.22 94.27 98.52 104.22 94.97 95.30 [12,] 79.96 102.15 113.48 95.15 94.21 101.77 105.26 94.68 95.93 > 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] 79.95583 86.13000 112.79750 105.36333 94.13167 96.78250 101.45167 [8] 100.00083 95.09167 > arr.sd [1] 1.3050633 7.3328662 2.5938218 7.3126843 0.2156105 2.0732018 2.4965825 [8] 4.7261083 0.6373216 > arr.range [1] 4.60 22.43 9.03 17.90 0.78 8.32 7.71 12.29 1.83 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean -0.25429 0.03554 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -10.108 2.368 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 3.63436 0.05986 > postscript(file="/var/wessaorg/rcomp/tmp/18bjz1447955049.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/2j8i91447955049.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/31i6p1447955049.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/4dihs1447955049.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/56txy1447955049.tab") > > try(system("convert tmp/18bjz1447955049.ps tmp/18bjz1447955049.png",intern=TRUE)) character(0) > try(system("convert tmp/2j8i91447955049.ps tmp/2j8i91447955049.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.846 0.188 1.039