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(93.6,103.5,127,117.5,111.5,137.6,103.2,86.9,124.4,113.6,101.6,148.5,108.3,117.2,128.7,116.5,131.7,139.9,107.4,96.1,126.5,116.4,109.8,148,111.4,117,141.7,120,132.1,146.7,122.5,99.6,122.7,139,117.8,125.5,134.5,121.3,126.7,117.7,123,132.1,113.1,89.2,121.7,105.3,85.3,105.3,72.2,92.1,97.2,78.6,78.1,93,81,65.9,88.6,85.7,76.3,96.8,76.8,85.6,119.2,91.4,95.7,112.3,95.2,82.8,111.3,108.2,97,124.4,99.3,117.6,131.5,114.2,116.8,116.5,105.4,89.2,115.8,111.4,106.4,128.4,107.7,111,129.8,130.5,142.9,159.9,84.1,75,100.7,106.8,97.4,113,76.9,87.3,103.7,92.1,92.9,112.2,88.7,74.6,101.5,119.7,120.7,153.5) > 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,] 93.6 108.3 111.4 134.5 72.2 76.8 99.3 107.7 76.9 [2,] 103.5 117.2 117.0 121.3 92.1 85.6 117.6 111.0 87.3 [3,] 127.0 128.7 141.7 126.7 97.2 119.2 131.5 129.8 103.7 [4,] 117.5 116.5 120.0 117.7 78.6 91.4 114.2 130.5 92.1 [5,] 111.5 131.7 132.1 123.0 78.1 95.7 116.8 142.9 92.9 [6,] 137.6 139.9 146.7 132.1 93.0 112.3 116.5 159.9 112.2 [7,] 103.2 107.4 122.5 113.1 81.0 95.2 105.4 84.1 88.7 [8,] 86.9 96.1 99.6 89.2 65.9 82.8 89.2 75.0 74.6 [9,] 124.4 126.5 122.7 121.7 88.6 111.3 115.8 100.7 101.5 [10,] 113.6 116.4 139.0 105.3 85.7 108.2 111.4 106.8 119.7 [11,] 101.6 109.8 117.8 85.3 76.3 97.0 106.4 97.4 120.7 [12,] 148.5 148.0 125.5 105.3 96.8 124.4 128.4 113.0 153.5 > 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] 114.07500 120.54167 124.66667 114.60000 83.79167 99.99167 112.70833 [8] 113.23333 101.98333 > arr.sd [1] 18.02570 14.87912 13.40830 15.67575 10.03326 15.00348 11.65227 24.16957 [9] 22.10918 > arr.range [1] 61.6 51.9 47.1 49.2 31.3 47.6 42.3 84.9 78.9 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 8.15106 0.07264 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -0.6765 0.7292 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 17.8393 0.3391 > postscript(file="/var/wessaorg/rcomp/tmp/1l8b71426178656.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/2n8521426178656.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/3dcbe1426178657.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/4tg2c1426178657.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/5py6i1426178657.tab") > > try(system("convert tmp/1l8b71426178656.ps tmp/1l8b71426178656.png",intern=TRUE)) character(0) > try(system("convert tmp/2n8521426178656.ps tmp/2n8521426178656.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.868 0.159 1.038