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(1474200,1419600,1501500,1201200,1556100,1528800,1638000,1692600,1883700,1638000,1556100,1938300,1638000,1228500,1446900,1092000,1528800,1255800,1665300,1501500,1583400,1774500,1747200,2074800,1501500,1255800,1392300,1010100,1446900,1119300,1583400,1501500,1337700,1911000,1719900,1965600,1474200,1365000,1228500,1010100,1337700,1201200,1638000,1583400,1365000,1829100,1692600,2184000,1747200,1064700,1064700,1064700,1255800,1255800,1692600,1556100,1392300,1747200,1610700,2320500,1829100,1064700,1119300,928200,1283100,1474200,1856400,1829100,1474200,1719900,1528800,2184000,1665300,1337700,1201200,900900,1337700,1610700,1883700,1774500,1310400,1883700,1474200,2265900,1883700,1365000,1255800,846300,1337700,1283100,1938300,1938300,1474200,1911000,1419600,2211300,1883700,1392300,1064700,737100,1446900,1392300,1829100,2102100,1556100,1747200,1310400,2265900) > 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,] 1474200 1638000 1501500 1474200 1747200 1829100 1665300 1883700 1883700 [2,] 1419600 1228500 1255800 1365000 1064700 1064700 1337700 1365000 1392300 [3,] 1501500 1446900 1392300 1228500 1064700 1119300 1201200 1255800 1064700 [4,] 1201200 1092000 1010100 1010100 1064700 928200 900900 846300 737100 [5,] 1556100 1528800 1446900 1337700 1255800 1283100 1337700 1337700 1446900 [6,] 1528800 1255800 1119300 1201200 1255800 1474200 1610700 1283100 1392300 [7,] 1638000 1665300 1583400 1638000 1692600 1856400 1883700 1938300 1829100 [8,] 1692600 1501500 1501500 1583400 1556100 1829100 1774500 1938300 2102100 [9,] 1883700 1583400 1337700 1365000 1392300 1474200 1310400 1474200 1556100 [10,] 1638000 1774500 1911000 1829100 1747200 1719900 1883700 1911000 1747200 [11,] 1556100 1747200 1719900 1692600 1610700 1528800 1474200 1419600 1310400 [12,] 1938300 2074800 1965600 2184000 2320500 2184000 2265900 2211300 2265900 > 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] 1585675 1544725 1478750 1492400 1481025 1524250 1553825 1572025 1560650 > arr.sd [1] 197707.4 269618.3 289345.7 316948.0 374522.3 376994.1 369116.4 396548.3 [9] 432565.6 > arr.range [1] 737100 982800 955500 1173900 1255800 1255800 1365000 1365000 1528800 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 5.006e+05 -1.074e-01 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) 31.163 -1.296 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 8.383e+05 2.229e-01 > postscript(file="/var/wessaorg/rcomp/tmp/13itp1439753195.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/2e7jz1439753195.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/3pl4p1439753195.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/4s3rw1439753195.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/5o92i1439753195.tab") > > try(system("convert tmp/13itp1439753195.ps tmp/13itp1439753195.png",intern=TRUE)) character(0) > try(system("convert tmp/2e7jz1439753195.ps tmp/2e7jz1439753195.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.885 0.189 1.065