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(82.75,83.4,84.12,83.88,83.61,83.58,83.58,83.27,83.59,83.64,83.72,83.88,83.61,85.36,87.2,88.28,88.64,88.67,88.34,89.21,89.55,89.65,88.43,91.15,94.11,96.78,97.94,97.57,96.48,96.18,95,93.84,95.54,94.06,93.92,92.55,93.88,92.19,91.42,91.39,89.12,90.27,91.76,95.68,97.54,98.47,100.11,99.9,101.11,98.86,102.71,102.02,100.61,100.62,99.51,98.63,97.44,96.5,94.3,92.92,96.07,95,93.27,91.94,91.62,91.01,90.62,97.72,99.09,99.72,100.22,99.15,101.16,101.8,103.31,101.19,99.09,95.91,94.56,95.76,100.36,102.67,103.58,100.89,103.46,104.86,104.88,104.46,103.83,101,99.36,96.71,95.23,95.62,95.8,94.79,95.39,94.9,94.84,94.68,94.17,94.1,93.84,94.2,97.76,98.26,99.63,98.75) > 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,] 82.75 83.61 94.11 93.88 101.11 96.07 101.16 103.46 95.39 [2,] 83.40 85.36 96.78 92.19 98.86 95.00 101.80 104.86 94.90 [3,] 84.12 87.20 97.94 91.42 102.71 93.27 103.31 104.88 94.84 [4,] 83.88 88.28 97.57 91.39 102.02 91.94 101.19 104.46 94.68 [5,] 83.61 88.64 96.48 89.12 100.61 91.62 99.09 103.83 94.17 [6,] 83.58 88.67 96.18 90.27 100.62 91.01 95.91 101.00 94.10 [7,] 83.58 88.34 95.00 91.76 99.51 90.62 94.56 99.36 93.84 [8,] 83.27 89.21 93.84 95.68 98.63 97.72 95.76 96.71 94.20 [9,] 83.59 89.55 95.54 97.54 97.44 99.09 100.36 95.23 97.76 [10,] 83.64 89.65 94.06 98.47 96.50 99.72 102.67 95.62 98.26 [11,] 83.72 88.43 93.92 100.11 94.30 100.22 103.58 95.80 99.63 [12,] 83.88 91.15 92.55 99.90 92.92 99.15 100.89 94.79 98.75 > 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] 83.58500 88.17417 95.33083 94.31083 98.76917 95.45250 100.02333 [8] 100.00000 95.87667 > arr.sd [1] 0.3454773 2.0060520 1.6832893 3.8826127 3.0161729 3.6736039 3.0591987 [8] 4.1878743 2.0953773 > arr.range [1] 1.37 7.54 5.39 10.99 9.79 9.60 9.02 10.09 5.79 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean -13.2703 0.1684 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -47.44 10.61 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean -29.8988 0.3977 > postscript(file="/var/wessaorg/rcomp/tmp/1vlfw1447843085.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/2p6bo1447843085.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/3ad5d1447843085.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/4phsw1447843085.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/5fkj11447843085.tab") > > try(system("convert tmp/1vlfw1447843085.ps tmp/1vlfw1447843085.png",intern=TRUE)) character(0) > try(system("convert tmp/2p6bo1447843085.ps tmp/2p6bo1447843085.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.792 0.182 0.970