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(96.01,96.39,97.16,97.46,97.6,97.02,96.95,97.23,98,98.04,97.76,96.99,97.44,98,98.84,98.98,98.92,98.63,98.52,98.97,99.74,99.68,99.45,98.97,98.68,99.06,99.84,100.3,100.38,100.02,99.83,100.36,100.74,100.49,100.33,99.96,100.08,100.54,101.63,102.12,102.19,101.77,101.29,101.47,102.07,102.11,102.26,101.83,102.11,102.8,103.82,104.2,104.57,104.38,104.54,104.74,105.19,104.95,104.57,103.81,104.08,104.81,105.86,106.1,106.24,105.87,104.74,105.03,105.59,105.69,105.58,104.96,104.93,105.68,106.93,107.29,107.25,106.74,106.44,106.6,107.26,107.35,107.22,106.99,107,107.74,109.02,109.54,109.71,109.18,109.23,109.38,110.17,110.15,110.01,109.54,109.52,110.35,111.61,112.06,111.9,111.36,112.09,112.24,112.7,113.36,112.9,112.74,112.77,113.66,114.87,114.97,115,114.57,115.54,115.39,115.46,115.13,114.56,114.62) > 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] 120 > (np <- floor(n / par1)) [1] 10 > 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] [,10] [1,] 96.01 97.44 98.68 100.08 102.11 104.08 104.93 107.00 109.52 112.77 [2,] 96.39 98.00 99.06 100.54 102.80 104.81 105.68 107.74 110.35 113.66 [3,] 97.16 98.84 99.84 101.63 103.82 105.86 106.93 109.02 111.61 114.87 [4,] 97.46 98.98 100.30 102.12 104.20 106.10 107.29 109.54 112.06 114.97 [5,] 97.60 98.92 100.38 102.19 104.57 106.24 107.25 109.71 111.90 115.00 [6,] 97.02 98.63 100.02 101.77 104.38 105.87 106.74 109.18 111.36 114.57 [7,] 96.95 98.52 99.83 101.29 104.54 104.74 106.44 109.23 112.09 115.54 [8,] 97.23 98.97 100.36 101.47 104.74 105.03 106.60 109.38 112.24 115.39 [9,] 98.00 99.74 100.74 102.07 105.19 105.59 107.26 110.17 112.70 115.46 [10,] 98.04 99.68 100.49 102.11 104.95 105.69 107.35 110.15 113.36 115.13 [11,] 97.76 99.45 100.33 102.26 104.57 105.58 107.22 110.01 112.90 114.56 [12,] 96.99 98.97 99.96 101.83 103.81 104.96 106.99 109.54 112.74 114.62 > 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] 97.21750 98.84500 99.99917 101.61333 104.14000 105.37917 106.72333 [8] 109.22250 111.90250 114.71167 > arr.sd [1] 0.6102775 0.6577717 0.5987177 0.6850791 0.8963258 0.6489216 0.7410108 [8] 0.9545311 1.0911639 0.7967985 > arr.range [1] 2.03 2.30 2.06 2.18 3.08 2.16 2.42 3.17 3.84 2.77 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean -1.38697 0.02053 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -13.201 2.777 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean -5.18080 0.07413 > postscript(file="/var/wessaorg/rcomp/tmp/1k5ll1425901990.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/2y3al1425901990.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/3qumk1425901990.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/46wht1425901990.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/5k3ur1425901990.tab") > > try(system("convert tmp/1k5ll1425901990.ps tmp/1k5ll1425901990.png",intern=TRUE)) character(0) > try(system("convert tmp/2y3al1425901990.ps tmp/2y3al1425901990.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.849 0.118 0.975