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(369.07,369.32,370.38,371.63,371.32,371.51,369.69,368.18,366.87,366.94,368.27,369.62,370.47,371.44,372.39,373.32,373.77,373.13,371.51,369.59,368.12,368.38,369.64,371.11,372.38,373.08,373.87,374.93,375.58,375.44,373.91,371.77,370.72,370.5,372.19,373.71,374.92,375.63,376.51,377.75,378.54,378.21,376.65,374.28,373.12,373.1,374.67,375.97,377.03,377.87,378.88,380.42,380.62,379.66,377.48,376.07,374.1,374.47,376.15,377.51,378.43,379.7,380.91,382.2,382.45,382.14,380.6,378.6,376.72,376.98,378.29,380.07,381.36,382.19,382.65,384.65,384.94,384.01,382.15,380.33,378.81,379.06,380.17,381.85,382.88,383.77,384.42,386.36,386.53,386.01,384.45,381.96,380.81,381.09,382.37,383.84,385.42,385.72,385.96,387.18,388.5,387.88,386.38,384.15,383.07,382.98,384.11,385.54,386.92,387.41,388.77,389.46,390.18,389.43,387.74,385.91,384.77,384.38,385.99,387.26,388.45,389.7,391.08,392.46,392.96,392.03,390.13,388.15,386.8,387.18,388.59) > 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] 131 > (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] [,10] [1,] 369.07 370.47 372.38 374.92 377.03 378.43 381.36 382.88 385.42 386.92 [2,] 369.32 371.44 373.08 375.63 377.87 379.70 382.19 383.77 385.72 387.41 [3,] 370.38 372.39 373.87 376.51 378.88 380.91 382.65 384.42 385.96 388.77 [4,] 371.63 373.32 374.93 377.75 380.42 382.20 384.65 386.36 387.18 389.46 [5,] 371.32 373.77 375.58 378.54 380.62 382.45 384.94 386.53 388.50 390.18 [6,] 371.51 373.13 375.44 378.21 379.66 382.14 384.01 386.01 387.88 389.43 [7,] 369.69 371.51 373.91 376.65 377.48 380.60 382.15 384.45 386.38 387.74 [8,] 368.18 369.59 371.77 374.28 376.07 378.60 380.33 381.96 384.15 385.91 [9,] 366.87 368.12 370.72 373.12 374.10 376.72 378.81 380.81 383.07 384.77 [10,] 366.94 368.38 370.50 373.10 374.47 376.98 379.06 381.09 382.98 384.38 [11,] 368.27 369.64 372.19 374.67 376.15 378.29 380.17 382.37 384.11 385.99 [12,] 369.62 371.11 373.71 375.97 377.51 380.07 381.85 383.84 385.54 387.26 > 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] 369.4000 371.0725 373.1733 375.7792 377.5217 379.7575 381.8475 383.7075 [9] 385.5742 387.3517 > arr.sd [1] 1.638664 1.887866 1.707515 1.839750 2.127563 1.982359 2.029282 1.957699 [9] 1.770287 1.872115 > arr.range [1] 4.76 5.65 5.08 5.44 6.52 5.73 6.13 5.72 5.52 5.80 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean -1.551438 0.009069 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -10.89 1.94 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean -9.08407 0.03889 > postscript(file="/var/wessaorg/rcomp/tmp/1drig1354113703.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/28vp51354113703.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/3vqf51354113704.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/4b1jx1354113704.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/5br9x1354113704.tab") > > try(system("convert tmp/1drig1354113703.ps tmp/1drig1354113703.png",intern=TRUE)) character(0) > try(system("convert tmp/28vp51354113703.ps tmp/28vp51354113703.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.322 0.230 1.532