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(88.83,89.01,88.21,87.78,87.93,88.11,88.2,88.12,88.38,87.65,88.24,87.83,87.75,87.88,87.61,88.05,87.77,87.79,88.34,88.48,88.75,87.95,89.09,88.73,89.24,89.77,89.84,90.97,91.53,92.2,92.27,92.42,92.07,91.73,92.1,91.68,92.63,93.02,92.66,93.23,93.79,93.92,94.04,94.23,94.37,94.29,94.38,94,94.11,93.98,93.42,93.3,93.32,93.75,93.82,94.06,94.09,93.64,93.9,93.18,93.54,93.55,93.8,93.39,93.27,93.58,93.47,93.75,93.3,92.65,92.96,92.84,93.29,93.57,93.54,94.38,93.98,94.48,94.63,95.45,95.59,94.76,95.66,95.03,96.45,97.15,97.5,98.54,99.54,100.33,100.28,101.81,101.91,101.92,102.68,101.9,102.14,102.3,102.06,102.4,102.99,102.99,102.83,103.01,102.6,102.18,102.6,101.44) > 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,] 88.83 87.75 89.24 92.63 94.11 93.54 93.29 96.45 102.14 [2,] 89.01 87.88 89.77 93.02 93.98 93.55 93.57 97.15 102.30 [3,] 88.21 87.61 89.84 92.66 93.42 93.80 93.54 97.50 102.06 [4,] 87.78 88.05 90.97 93.23 93.30 93.39 94.38 98.54 102.40 [5,] 87.93 87.77 91.53 93.79 93.32 93.27 93.98 99.54 102.99 [6,] 88.11 87.79 92.20 93.92 93.75 93.58 94.48 100.33 102.99 [7,] 88.20 88.34 92.27 94.04 93.82 93.47 94.63 100.28 102.83 [8,] 88.12 88.48 92.42 94.23 94.06 93.75 95.45 101.81 103.01 [9,] 88.38 88.75 92.07 94.37 94.09 93.30 95.59 101.91 102.60 [10,] 87.65 87.95 91.73 94.29 93.64 92.65 94.76 101.92 102.18 [11,] 88.24 89.09 92.10 94.38 93.90 92.96 95.66 102.68 102.60 [12,] 87.83 88.73 91.68 94.00 93.18 92.84 95.03 101.90 101.44 > 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] 88.19083 88.18250 91.31833 93.71333 93.71417 93.34167 94.53000 [8] 100.00083 102.46167 > arr.sd [1] 0.4033149 0.4824959 1.1054150 0.6543607 0.3356800 0.3590096 0.8161216 [8] 2.1512891 0.4720137 > arr.range [1] 1.36 1.48 3.18 1.75 0.93 1.15 2.37 6.23 1.57 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean -3.91907 0.04974 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -19.999 4.299 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean -11.4020 0.1451 > postscript(file="/var/wessaorg/rcomp/tmp/1saxw1448213526.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/2jso71448213526.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/3eftc1448213526.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/4ks9d1448213526.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/5m0sc1448213526.tab") > > try(system("convert tmp/1saxw1448213526.ps tmp/1saxw1448213526.png",intern=TRUE)) character(0) > try(system("convert tmp/2jso71448213526.ps tmp/2jso71448213526.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.905 0.165 1.070