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(498.10,498.76,498.88,498.88,498.88,498.88,499.48,501.21,502.05,502.05,502.05,504.10,506.81,516.88,520.43,520.68,520.68,520.68,521.03,521.25,521.25,521.25,521.65,521.65,522.77,518.72,519.27,519.38,521.29,521.29,521.29,523.47,523.86,524.14,524.14,524.14,534.60,534.99,535.39,535.39,535.39,535.39,535.39,535.64,536.08,537.80,537.80,537.80,537.85,544.39,545.15,544.65,544.65,544.65,545.73,548.94,550.94,551.22,551.22,551.22,553.12,565.37,566.73,566.73,566.78,566.78,566.78,566.78,566.93,566.93,566.93,566.93,574.38,574.40,574.40,574.40,574.40,574.40,574.50,574.50,574.67,574.66,574.66,574.94,576.10,583.38,584.15,584.15,584.15,584.15,585.14,585.14,585.67,586.49,586.81,586.85) > 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,] 498.10 506.81 522.77 534.60 537.85 553.12 574.38 576.10 [2,] 498.76 516.88 518.72 534.99 544.39 565.37 574.40 583.38 [3,] 498.88 520.43 519.27 535.39 545.15 566.73 574.40 584.15 [4,] 498.88 520.68 519.38 535.39 544.65 566.73 574.40 584.15 [5,] 498.88 520.68 521.29 535.39 544.65 566.78 574.40 584.15 [6,] 498.88 520.68 521.29 535.39 544.65 566.78 574.40 584.15 [7,] 499.48 521.03 521.29 535.39 545.73 566.78 574.50 585.14 [8,] 501.21 521.25 523.47 535.64 548.94 566.78 574.50 585.14 [9,] 502.05 521.25 523.86 536.08 550.94 566.93 574.67 585.67 [10,] 502.05 521.25 524.14 537.80 551.22 566.93 574.66 586.49 [11,] 502.05 521.65 524.14 537.80 551.22 566.93 574.66 586.81 [12,] 504.10 521.65 524.14 537.80 551.22 566.93 574.94 586.85 > 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] 500.2767 519.5200 521.9800 535.9717 546.7175 565.5658 574.5258 584.3483 > arr.sd [1] 1.9164045 4.1964400 2.0568157 1.1554994 4.0887009 3.9426375 0.1732291 [8] 2.8450142 > arr.range [1] 6.00 14.84 5.42 3.20 13.37 13.81 0.56 10.75 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 4.063165 -0.002789 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) 31.997 -4.982 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 4.869170 0.006668 > postscript(file="/var/wessaorg/rcomp/tmp/12tc91432660553.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/2mekc1432660553.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/3qo3w1432660553.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/41c4v1432660553.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/5hvjz1432660553.tab") > > try(system("convert tmp/12tc91432660553.ps tmp/12tc91432660553.png",intern=TRUE)) character(0) > try(system("convert tmp/2mekc1432660553.ps tmp/2mekc1432660553.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.872 0.162 1.034