R version 3.0.1 (2013-05-16) -- "Good Sport" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-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(865911,858030,850038,833499,997113,988455,865911,784437,792318,792318,801087,816849,865911,850038,874569,914862,1144188,1144188,1095237,1046175,1086468,1135530,1144188,1168719,1242312,1193250,1193250,1266843,1470861,1487400,1446330,1348206,1421799,1421799,1429680,1470861,1503273,1519812,1519812,1568874,1757130,1806081,1813962,1691418,1757130,1732599,1683537,1789542,1813962,1772892,1781550,1838493,2051280,2157174,2157174,2108223,2181705,2108223,2067042,2222886,2247306,2189586,2336661,2394381,2565987,2679873,2664111,2655342,2721054,2713062,2615049,2762124,2811186,2762124,2966142,3064266,3292704,3382836,3358416,3309354,3350424,3399486,3235761,3366297,3448548,3415359,3628035,3701517,4012317,4069260,3995778,4036848,4061379,4085910,3930066,4077141,4158615,4077141,4314459,4387941,4706622,4755684,4771446,4853697,4853697,4886109,4739034,4812627,4861578,4771446,5033184,5082246,5408808,5466528,5548002,5621595,5629476,5638134,5491059,5638134) > 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,] 865911 865911 1242312 1503273 1813962 2247306 2811186 3448548 4158615 [2,] 858030 850038 1193250 1519812 1772892 2189586 2762124 3415359 4077141 [3,] 850038 874569 1193250 1519812 1781550 2336661 2966142 3628035 4314459 [4,] 833499 914862 1266843 1568874 1838493 2394381 3064266 3701517 4387941 [5,] 997113 1144188 1470861 1757130 2051280 2565987 3292704 4012317 4706622 [6,] 988455 1144188 1487400 1806081 2157174 2679873 3382836 4069260 4755684 [7,] 865911 1095237 1446330 1813962 2157174 2664111 3358416 3995778 4771446 [8,] 784437 1046175 1348206 1691418 2108223 2655342 3309354 4036848 4853697 [9,] 792318 1086468 1421799 1757130 2181705 2721054 3350424 4061379 4853697 [10,] 792318 1135530 1421799 1732599 2108223 2713062 3399486 4085910 4886109 [11,] 801087 1144188 1429680 1683537 2067042 2615049 3235761 3930066 4739034 [12,] 816849 1168719 1470861 1789542 2222886 2762124 3366297 4077141 4812627 [,10] [1,] 4861578 [2,] 4771446 [3,] 5033184 [4,] 5082246 [5,] 5408808 [6,] 5466528 [7,] 5548002 [8,] 5621595 [9,] 5629476 [10,] 5638134 [11,] 5491059 [12,] 5638134 > 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] 853830.5 1039172.8 1366049.2 1678597.5 2021717.0 2545378.0 3191583.0 [8] 3871846.5 4609756.0 5349182.5 > arr.sd [1] 71301.82 125379.34 112248.62 118906.95 169755.03 199388.58 230731.52 [8] 253087.89 291342.61 321839.88 > arr.range [1] 212676 318681 294150 310689 449994 572538 637362 670551 808968 866688 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 4.883e+04 5.299e-02 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) 1.1376 0.7465 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 1.288e+05 1.453e-01 > postscript(file="/var/wessaorg/rcomp/tmp/15d951377070484.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/2bxr71377070484.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/3xvns1377070484.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/4idjn1377070484.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/52vsr1377070485.tab") > > try(system("convert tmp/15d951377070484.ps tmp/15d951377070484.png",intern=TRUE)) character(0) > try(system("convert tmp/2bxr71377070484.ps tmp/2bxr71377070484.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.482 0.394 1.855