R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 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(100.8,100.66,101.44,102.17,102.75,104.28,104.96,105.16,105.29,105.15,105.23,104.45,104.6,105.1,105.94,106.2,106.89,107.57,107.42,107.2,107.08,107.17,107.23,106.61,106.97,108.23,109.8,111.93,113.51,115.27,115.58,115.55,115.44,114.93,115.09,113.78,114.51,114.85,116.12,115.47,115.93,116.6,116.98,117.37,117.48,117.18,117.03,114.95,115.64,116.02,116.07,114.5,114.36,116,116.16,116.42,116.78,115.74,115.44,113.52,113.37,114.35,114.11,113.47,114.33,115.76,116.2,116.48,116.53,116.45,116.23,114.46,115.08,115.57,116.17,115.21,114.97,114.24,114.16,117.2,117.71,117.14,116.67,114.71,115.92,117.74,118.38,118.59,119.66,121.2,121.4,122.66,122.95,122.9,123.29,122.02) > 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] 96 > (np <- floor(n / par1)) [1] 8 > 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] [1,] 100.80 104.60 106.97 114.51 115.64 113.37 115.08 115.92 [2,] 100.66 105.10 108.23 114.85 116.02 114.35 115.57 117.74 [3,] 101.44 105.94 109.80 116.12 116.07 114.11 116.17 118.38 [4,] 102.17 106.20 111.93 115.47 114.50 113.47 115.21 118.59 [5,] 102.75 106.89 113.51 115.93 114.36 114.33 114.97 119.66 [6,] 104.28 107.57 115.27 116.60 116.00 115.76 114.24 121.20 [7,] 104.96 107.42 115.58 116.98 116.16 116.20 114.16 121.40 [8,] 105.16 107.20 115.55 117.37 116.42 116.48 117.20 122.66 [9,] 105.29 107.08 115.44 117.48 116.78 116.53 117.71 122.95 [10,] 105.15 107.17 114.93 117.18 115.74 116.45 117.14 122.90 [11,] 105.23 107.23 115.09 117.03 115.44 116.23 116.67 123.29 [12,] 104.45 106.61 113.78 114.95 113.52 114.46 114.71 122.02 > 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] 103.5283 106.5842 113.0067 116.2058 115.5542 115.1450 115.7358 120.5592 > arr.sd [1] 1.8399251 0.9463947 3.0707575 1.0564904 0.9549532 1.2382135 1.2123490 [8] 2.4350227 > arr.range [1] 4.63 2.97 8.61 2.97 3.26 3.16 3.55 7.37 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 0.006976 0.014011 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -2.9429 0.7011 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean -4.13797 0.07682 > postscript(file="/var/wessaorg/rcomp/tmp/17wyl1432591726.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/2ym0d1432591726.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/3n4s91432591726.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/4xj921432591726.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/5c2il1432591726.tab") > > try(system("convert tmp/17wyl1432591726.ps tmp/17wyl1432591726.png",intern=TRUE)) character(0) > try(system("convert tmp/2ym0d1432591726.ps tmp/2ym0d1432591726.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.885 0.168 1.055