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(3207324 + ,3178086 + ,3148485 + ,3087246 + ,3693267 + ,3661164 + ,3207324 + ,2905563 + ,2934699 + ,2934699 + ,2967168 + ,3025542 + ,3207324 + ,3148485 + ,3239325 + ,3388641 + ,4238049 + ,4238049 + ,4056732 + ,3874950 + ,4024266 + ,4205949 + ,4238049 + ,4328892 + ,4601499 + ,4419732 + ,4419732 + ,4692342 + ,5448042 + ,5509281 + ,5357202 + ,4993734 + ,5266260 + ,5266260 + ,5295495 + ,5448042 + ,5568120 + ,5629359 + ,5629359 + ,5811042 + ,6508356 + ,6689670 + ,6718809 + ,6264966 + ,6508356 + ,6417513 + ,6235746 + ,6628434 + ,6718809 + ,6566727 + ,6598830 + ,6809748 + ,7597920 + ,7990056 + ,7990056 + ,7808739 + ,8080980 + ,7808739 + ,7656276 + ,8233527 + ,8323902 + ,8110134 + ,8654901 + ,8868684 + ,9504309 + ,9926133 + ,9867774 + ,9835290 + ,10078677 + ,10049076 + ,9686076 + ,10230759 + ,10412541 + ,10230759 + ,10986462 + ,11349927 + ,12196086 + ,12529950 + ,12439476 + ,12257691 + ,12409872 + ,12591555 + ,11985168 + ,12468612 + ,12773337 + ,12650394 + ,13438098 + ,13710240 + ,14861511 + ,15072414 + ,14800254 + ,14952351 + ,15043194 + ,15134034 + ,14556783 + ,15101568 + ,15403311 + ,15101568 + ,15980562 + ,16252821 + ,17433111 + ,17614893 + ,17673267 + ,17977893 + ,17977893 + ,18097971 + ,17553189 + ,17825814 + ,18007131 + ,17673267 + ,18642738 + ,18824436 + ,20034063 + ,20247849 + ,20549592 + ,20822217 + ,20851353 + ,20883456 + ,20338689 + ,20883456) > 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] [1,] 3207324 3207324 4601499 5568120 6718809 8323902 10412541 12773337 [2,] 3178086 3148485 4419732 5629359 6566727 8110134 10230759 12650394 [3,] 3148485 3239325 4419732 5629359 6598830 8654901 10986462 13438098 [4,] 3087246 3388641 4692342 5811042 6809748 8868684 11349927 13710240 [5,] 3693267 4238049 5448042 6508356 7597920 9504309 12196086 14861511 [6,] 3661164 4238049 5509281 6689670 7990056 9926133 12529950 15072414 [7,] 3207324 4056732 5357202 6718809 7990056 9867774 12439476 14800254 [8,] 2905563 3874950 4993734 6264966 7808739 9835290 12257691 14952351 [9,] 2934699 4024266 5266260 6508356 8080980 10078677 12409872 15043194 [10,] 2934699 4205949 5266260 6417513 7808739 10049076 12591555 15134034 [11,] 2967168 4238049 5295495 6235746 7656276 9686076 11985168 14556783 [12,] 3025542 4328892 5448042 6628434 8233527 10230759 12468612 15101568 [,9] [,10] [1,] 15403311 18007131 [2,] 15101568 17673267 [3,] 15980562 18642738 [4,] 16252821 18824436 [5,] 17433111 20034063 [6,] 17614893 20247849 [7,] 17673267 20549592 [8,] 17977893 20822217 [9,] 17977893 20851353 [10,] 18097971 20883456 [11,] 17553189 20338689 [12,] 17825814 20883456 > 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] 3162547 3849059 5059802 6217478 7488367 9427976 11821508 14341182 [9] 17074358 19813187 > arr.sd [1] 264096.3 464409.1 415774.5 440416.1 628761.3 738530.9 854633.0 [8] 937422.7 1079127.8 1192084.5 > arr.range [1] 787704 1180407 1089549 1150689 1666800 2120625 2360796 2483640 2996403 [10] 3210189 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 1.809e+05 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.4696 0.7465 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 4.769e+05 1.453e-01 > postscript(file="/var/wessaorg/rcomp/tmp/1lmdj1375886601.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/2nhv91375886601.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/3tges1375886601.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/4r3lt1375886601.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/5pocq1375886601.tab") > > try(system("convert tmp/1lmdj1375886601.ps tmp/1lmdj1375886601.png",intern=TRUE)) character(0) > try(system("convert tmp/2nhv91375886601.ps tmp/2nhv91375886601.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.854 0.503 2.327