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(5204472,5185089,5165433,5124756,5527158,5505864,5204472,5004090,5023473,5023473,5045040,5083806,5144139,5144139,5105373,5004090,5527158,5606874,5486481,5204472,5325138,5144139,5225766,5264805,5305482,5204472,5225766,5083806,5527158,5667207,5546814,5325138,5566197,5305482,5546814,5527158,5587491,5365815,5606874,5587491,5949216,5867589,5546814,5385198,5606874,5305482,5527158,5566197,5647824,5467098,5566197,5626530,5848206,5667207,5426148,5165433,5406765,4743375,5064423,5245149,5426148,5165433,5165433,5165433,5305482,5105373,4842747,4622982,4782414,4159974,4541355,4763031,4803708,4582032,4601415,4541355,4743375,4601415,4321590,4119297,4461366,3718533,4200924,4420689,4420689,4159974,3918915,3899532,4119297,3918915,3537807,3275181,3557190,2894073,3496857,3817632,3918915,3697239,3417141,3617523,3697239,3636906,3033849,2754024,2954133,2351349,2973789,3195465,3376191,3074799,2792790,2954133,3033849,2874417,2271633,2009007,2250066,1586949,2310399,2754024) > 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,] 5204472 5144139 5305482 5587491 5647824 5426148 4803708 4420689 3918915 [2,] 5185089 5144139 5204472 5365815 5467098 5165433 4582032 4159974 3697239 [3,] 5165433 5105373 5225766 5606874 5566197 5165433 4601415 3918915 3417141 [4,] 5124756 5004090 5083806 5587491 5626530 5165433 4541355 3899532 3617523 [5,] 5527158 5527158 5527158 5949216 5848206 5305482 4743375 4119297 3697239 [6,] 5505864 5606874 5667207 5867589 5667207 5105373 4601415 3918915 3636906 [7,] 5204472 5486481 5546814 5546814 5426148 4842747 4321590 3537807 3033849 [8,] 5004090 5204472 5325138 5385198 5165433 4622982 4119297 3275181 2754024 [9,] 5023473 5325138 5566197 5606874 5406765 4782414 4461366 3557190 2954133 [10,] 5023473 5144139 5305482 5305482 4743375 4159974 3718533 2894073 2351349 [11,] 5045040 5225766 5546814 5527158 5064423 4541355 4200924 3496857 2973789 [12,] 5083806 5264805 5527158 5566197 5245149 4763031 4420689 3817632 3195465 [,10] [1,] 3376191 [2,] 3074799 [3,] 2792790 [4,] 2954133 [5,] 3033849 [6,] 2874417 [7,] 2271633 [8,] 2009007 [9,] 2250066 [10,] 1586949 [11,] 2310399 [12,] 2754024 > 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] 5174760 5265214 5402624 5575183 5406196 4920484 4426308 3751338 3270631 [10] 2607355 > arr.sd [1] 175363.9 186072.9 182513.8 186735.9 307509.3 366633.7 301511.1 420238.8 [9] 469252.9 519333.6 > arr.range [1] 523068 602784 583401 643734 1104831 1266174 1085175 1526616 1567566 [10] 1789242 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 8.298e+05 -1.132e-01 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) 33.787 -1.386 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 2.893e+06 -3.983e-01 > postscript(file="/var/wessaorg/rcomp/tmp/1wx2t1439736538.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/2b1411439736538.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/3lbmx1439736538.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/4i6bz1439736538.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/55wc91439736538.tab") > > try(system("convert tmp/1wx2t1439736538.ps tmp/1wx2t1439736538.png",intern=TRUE)) character(0) > try(system("convert tmp/2b1411439736538.ps tmp/2b1411439736538.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.892 0.148 1.042