R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(571000 + ,584000 + ,599000 + ,582000 + ,530000 + ,528000 + ,536000 + ,546000 + ,559000 + ,562000 + ,541000 + ,539000 + ,548000 + ,563000 + ,581000 + ,572000 + ,519000 + ,521000 + ,531000 + ,540000 + ,548000 + ,556000 + ,551000 + ,549000 + ,564000 + ,586000 + ,604000 + ,601000 + ,545000 + ,537000 + ,552000 + ,563000 + ,575000 + ,580000 + ,575000 + ,558000 + ,564000 + ,581000 + ,597000 + ,587000 + ,536000 + ,524000 + ,537000 + ,536000 + ,533000 + ,528000 + ,516000 + ,502000 + ,506000 + ,518000 + ,534000 + ,528000 + ,478000 + ,469000 + ,490000 + ,493000 + ,508000 + ,517000 + ,514000 + ,510000 + ,527000 + ,542000 + ,565000 + ,555000 + ,499000 + ,511000 + ,526000 + ,532000 + ,549000 + ,561000 + ,557000 + ,566000 + ,588000 + ,620000 + ,626000 + ,620000 + ,573000 + ,573000 + ,574000 + ,580000 + ,590000 + ,593000 + ,597000 + ,595000 + ,612000 + ,628000 + ,629000 + ,621000 + ,569000 + ,567000 + ,573000 + ,584000 + ,589000 + ,591000 + ,595000 + ,594000 + ,611000 + ,613000 + ,611000 + ,594000 + ,543000 + ,537000 + ,544000 + ,555000 + ,561000 + ,562000 + ,555000 + ,547000 + ,565000 + ,578000 + ,580000 + ,569000 + ,507000 + ,501000 + ,509000 + ,510000 + ,517000 + ,519000 + ,512000 + ,509000 + ,519000 + ,523000 + ,525000 + ,517000 + ,456000 + ,455000 + ,461000 + ,470000 + ,475000 + ,476000 + ,471000 + ,471000 + ,503000 + ,513000 + ,510000 + ,484000 + ,431000 + ,436000 + ,443000 + ,448000 + ,460000 + ,467000 + ,460000 + ,464000 + ,485000 + ,501000 + ,521000 + ,488000 + ,439000 + ,442000 + ,457000 + ,462000 + ,481000 + ,493000) > 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] 154 > (np <- floor(n / par1)) [1] 12 > 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] [,10] [1,] 571000 548000 564000 564000 506000 527000 588000 612000 611000 565000 [2,] 584000 563000 586000 581000 518000 542000 620000 628000 613000 578000 [3,] 599000 581000 604000 597000 534000 565000 626000 629000 611000 580000 [4,] 582000 572000 601000 587000 528000 555000 620000 621000 594000 569000 [5,] 530000 519000 545000 536000 478000 499000 573000 569000 543000 507000 [6,] 528000 521000 537000 524000 469000 511000 573000 567000 537000 501000 [7,] 536000 531000 552000 537000 490000 526000 574000 573000 544000 509000 [8,] 546000 540000 563000 536000 493000 532000 580000 584000 555000 510000 [9,] 559000 548000 575000 533000 508000 549000 590000 589000 561000 517000 [10,] 562000 556000 580000 528000 517000 561000 593000 591000 562000 519000 [11,] 541000 551000 575000 516000 514000 557000 597000 595000 555000 512000 [12,] 539000 549000 558000 502000 510000 566000 595000 594000 547000 509000 [,11] [,12] [1,] 519000 503000 [2,] 523000 513000 [3,] 525000 510000 [4,] 517000 484000 [5,] 456000 431000 [6,] 455000 436000 [7,] 461000 443000 [8,] 470000 448000 [9,] 475000 460000 [10,] 476000 467000 [11,] 471000 460000 [12,] 471000 464000 > 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] 556416.7 548250.0 570000.0 545083.3 505416.7 540833.3 594083.3 596000.0 [9] 569416.7 531333.3 484916.7 468250.0 > arr.sd [1] 23453.86 18796.16 20867.55 30022.59 19519.03 21916.51 18870.17 21983.46 [9] 29234.03 31326.24 27533.31 28336.05 > arr.range [1] 71000 62000 67000 95000 65000 67000 53000 62000 76000 79000 70000 82000 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 4.832e+04 -4.424e-02 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) 22.8290 -0.9656 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 1.323e+05 -1.135e-01 > postscript(file="/var/wessaorg/rcomp/tmp/1rgke1353432906.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/2o0u21353432906.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/3uiyj1353432906.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/4sqjk1353432907.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/5p0ut1353432907.tab") > > try(system("convert tmp/1rgke1353432906.ps tmp/1rgke1353432906.png",intern=TRUE)) character(0) > try(system("convert tmp/2o0u21353432906.ps tmp/2o0u21353432906.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.518 0.693 4.200