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(1.5469,1.5501,1.5494,1.5475,1.5449,1.5391,1.5578,1.5528,1.5496,1.549,1.5449,1.5479,1.5494,1.558,1.5691,1.5748,1.5564,1.5601,1.5687,1.5775,1.5841,1.5898,1.5922,1.5969,1.6155,1.6212,1.6124,1.6375,1.6506,1.6543,1.6567,1.6383,1.6475,1.6706,1.6485,1.6592,1.6203,1.608,1.572,1.5964,1.6247,1.6139,1.6193,1.6212,1.5942,1.5194,1.5162,1.5393,1.4935,1.4904,1.5083,1.5147,1.5118,1.5148,1.5202,1.5236,1.5148,1.5138,1.5105,1.502,1.4765,1.4671,1.4482,1.4337,1.4181,1.3767,1.346,1.3413,1.3089,1.3452,1.3442,1.2811,1.2779,1.2974,1.2867,1.2977,1.2537,1.2092,1.1766,1.1203,1.2005,1.2295,1.2307,1.2276,1.2108,1.2071,1.2061,1.2023,1.2012,1.2011,1.2011,1.2011,1.2089,1.2098,1.2052,1.2091,1.2288,1.2298,1.2266,1.2199,1.2418,1.2322,1.2366,1.2338,1.2338,1.2316,1.2316,1.2245) > 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,] 1.5469 1.5494 1.6155 1.6203 1.4935 1.4765 1.2779 1.2108 1.2288 [2,] 1.5501 1.5580 1.6212 1.6080 1.4904 1.4671 1.2974 1.2071 1.2298 [3,] 1.5494 1.5691 1.6124 1.5720 1.5083 1.4482 1.2867 1.2061 1.2266 [4,] 1.5475 1.5748 1.6375 1.5964 1.5147 1.4337 1.2977 1.2023 1.2199 [5,] 1.5449 1.5564 1.6506 1.6247 1.5118 1.4181 1.2537 1.2012 1.2418 [6,] 1.5391 1.5601 1.6543 1.6139 1.5148 1.3767 1.2092 1.2011 1.2322 [7,] 1.5578 1.5687 1.6567 1.6193 1.5202 1.3460 1.1766 1.2011 1.2366 [8,] 1.5528 1.5775 1.6383 1.6212 1.5236 1.3413 1.1203 1.2011 1.2338 [9,] 1.5496 1.5841 1.6475 1.5942 1.5148 1.3089 1.2005 1.2089 1.2338 [10,] 1.5490 1.5898 1.6706 1.5194 1.5138 1.3452 1.2295 1.2098 1.2316 [11,] 1.5449 1.5922 1.6485 1.5162 1.5105 1.3442 1.2307 1.2052 1.2316 [12,] 1.5479 1.5969 1.6592 1.5393 1.5020 1.2811 1.2276 1.2091 1.2245 > 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] 1.548325 1.573083 1.642692 1.587075 1.509867 1.382250 1.233983 1.205317 [9] 1.230917 > arr.sd [1] 0.004549151 0.015451792 0.018257973 0.040598413 0.009991754 0.064539016 [7] 0.053258953 0.003820003 0.005695745 > arr.range [1] 0.0187 0.0475 0.0582 0.1085 0.0332 0.1954 0.1774 0.0097 0.0219 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 0.04037 -0.01140 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -4.658 1.298 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 0.15060 -0.05304 > postscript(file="/var/wessaorg/rcomp/tmp/1k8cl1432665533.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/24jts1432665533.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/3gfv41432665533.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/4xnb61432665533.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/5y8in1432665533.tab") > > try(system("convert tmp/1k8cl1432665533.ps tmp/1k8cl1432665533.png",intern=TRUE)) character(0) > try(system("convert tmp/24jts1432665533.ps tmp/24jts1432665533.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.895 0.182 1.079