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(178421,139871,118159,109763,97415,119190,97903,96953,87888,84637,90549,95680,99371,79984,86752,85733,84906,78356,108895,101768,73285,65724,67457,67203,69273,80807,75129,74991,68157,73858,71349,85634,91624,116014,120033,108651,105378,138939,132974,135277,152741,158417,157460,193997,154089,147570,162924,153629,155907,197675,250708,266652,209842,165826,137152,150581,145973,126532,115437,119526,110856,97243,103876,116370,109616,98365,90440,88899,92358,88394,98219,113546,107168,77540,74944,75641,75910,87384,84615,80420,80784,79933,82118,91420,112426,114528,131025,116460,111258,155318,155078,134794,139985,198778,172436,169585,203702,282392,220658,194472,269246,215340,218319,195724,174614,172085,152347,189615,173804,145683,133550,121156,112040,120767,127019,136295,113425,107815,100298,97048,98750,98235,101254,139589,134921,80355,80396,82183,79709,90781) > par1 = '4' > par1 <- '4' > #'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] 130 > (np <- floor(n / par1)) [1] 32 > 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] [,11] [1,] 178421 97415 87888 99371 84906 73285 69273 68157 91624 105378 152741 [2,] 139871 119190 84637 79984 78356 65724 80807 73858 116014 138939 158417 [3,] 118159 97903 90549 86752 108895 67457 75129 71349 120033 132974 157460 [4,] 109763 96953 95680 85733 101768 67203 74991 85634 108651 135277 193997 [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [1,] 154089 155907 209842 145973 110856 109616 92358 107168 75910 80784 112426 [2,] 147570 197675 165826 126532 97243 98365 88394 77540 87384 79933 114528 [3,] 162924 250708 137152 115437 103876 90440 98219 74944 84615 82118 131025 [4,] 153629 266652 150581 119526 116370 88899 113546 75641 80420 91420 116460 [,23] [,24] [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32] [1,] 111258 139985 203702 269246 174614 173804 112040 113425 98750 134921 [2,] 155318 198778 282392 215340 172085 145683 120767 107815 98235 80355 [3,] 155078 172436 220658 218319 152347 133550 127019 100298 101254 80396 [4,] 134794 169585 194472 195724 189615 121156 136295 97048 139589 82183 > 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] 136553.50 102865.25 89688.50 87960.00 93481.25 68417.25 75050.00 [8] 74749.50 109080.50 128142.00 165653.75 154553.00 217735.50 165850.25 [15] 126867.00 107086.25 96830.00 98129.25 83823.25 82082.25 83563.75 [22] 118609.75 139112.00 170196.00 225306.00 224657.25 172165.25 143548.25 [29] 124030.25 104646.50 109457.00 94463.75 > arr.sd [1] 30659.321 10890.077 4668.975 8169.992 14242.683 3333.920 4709.087 [8] 7622.151 12555.803 15373.477 19057.693 6322.051 50679.374 31580.660 [15] 13536.206 8318.540 9479.291 11041.839 15601.783 5012.754 5314.139 [22] 8439.181 20912.819 24048.743 39572.228 31370.231 15310.776 22519.217 [29] 10226.952 7388.011 20131.234 26984.961 > arr.range [1] 68658 22237 11043 19387 30539 7561 11534 17477 28409 33561 [11] 41256 15354 110745 72690 30536 19127 20717 25152 32224 11474 [21] 11487 18599 44060 58793 87920 73522 37268 52648 24255 16377 [31] 41354 54566 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean -9373.0657 0.2051 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -9.390 1.615 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean -2.260e+04 4.715e-01 > postscript(file="/var/wessaorg/rcomp/tmp/1j25g1354565961.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/29ity1354565961.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/30j9e1354565961.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/44emq1354565961.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/5dg981354565961.tab") > > try(system("convert tmp/1j25g1354565961.ps tmp/1j25g1354565961.png",intern=TRUE)) character(0) > try(system("convert tmp/29ity1354565961.ps tmp/29ity1354565961.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.154 0.472 2.728