R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-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(588264,577918,567562,546859,756344,745987,588264,483527,493873,493873,504229,526055,462824,399492,347630,347630,546859,567562,409838,231412,325803,325803,399492,442021,431664,325803,378790,357986,536412,493873,325803,200263,315447,347630,378790,420195,336150,263595,294755,305101,577918,577918,420195,399492,462824,431664,515709,620447,641250,493873,452367,409838,694135,714939,661953,714939,704481,620447,714939,819676,862205,735641,651596,714939,987746,1071790,1051088,1092483,1082137,977399,1155825,1198354,1260562,1071790,998102,1082137,1282389,1460814,1418286,1418286,1439089,1366423,1555307,1555307,1523124,1344597,1376780,1397583,1534503,1712929,1586355,1649698,1596712,1565653,1807421,1754435,1680746,1576009,1680746,1733732,1796963,1880998,1796963,1848826,1785585,1775239,2037699,2059525,1975491,1828123,1953664,2006549,2069882,2164273,2069882,2143570,2111388,1996193,2237951,2237951) > 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] [1,] 588264 462824 431664 336150 641250 862205 1260562 1523124 1680746 [2,] 577918 399492 325803 263595 493873 735641 1071790 1344597 1576009 [3,] 567562 347630 378790 294755 452367 651596 998102 1376780 1680746 [4,] 546859 347630 357986 305101 409838 714939 1082137 1397583 1733732 [5,] 756344 546859 536412 577918 694135 987746 1282389 1534503 1796963 [6,] 745987 567562 493873 577918 714939 1071790 1460814 1712929 1880998 [7,] 588264 409838 325803 420195 661953 1051088 1418286 1586355 1796963 [8,] 483527 231412 200263 399492 714939 1092483 1418286 1649698 1848826 [9,] 493873 325803 315447 462824 704481 1082137 1439089 1596712 1785585 [10,] 493873 325803 347630 431664 620447 977399 1366423 1565653 1775239 [11,] 504229 399492 378790 515709 714939 1155825 1555307 1807421 2037699 [12,] 526055 442021 420195 620447 819676 1198354 1555307 1754435 2059525 [,10] [1,] 1975491 [2,] 1828123 [3,] 1953664 [4,] 2006549 [5,] 2069882 [6,] 2164273 [7,] 2069882 [8,] 2143570 [9,] 2111388 [10,] 1996193 [11,] 2237951 [12,] 2237951 > 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] 572729.6 400530.5 376054.7 433814.0 636903.1 965100.2 1325707.7 [8] 1570815.8 1804419.2 2066243.1 > arr.sd [1] 91553.56 95521.85 88117.83 120490.47 123031.38 181972.14 188917.20 [8] 147550.58 140262.78 121618.87 > arr.range [1] 272817 336150 336149 356852 409838 546758 557205 462824 483516 409828 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 1.023e+05 2.720e-02 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) 8.0888 0.2678 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 3.296e+05 8.623e-02 > postscript(file="/var/wessaorg/rcomp/tmp/1g0bg1343750610.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/2cfif1343750610.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/3qvfv1343750610.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/4u3wc1343750610.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/5pjwj1343750610.tab") > > try(system("convert tmp/1g0bg1343750610.ps tmp/1g0bg1343750610.png",intern=TRUE)) character(0) > try(system("convert tmp/2cfif1343750610.ps tmp/2cfif1343750610.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.980 0.217 1.187