R version 3.2.2 (2015-08-14) -- "Fire Safety" Copyright (C) 2015 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(340.7,343.5,345.3,346.9,349,351.4,353,355,360.1,364.7,366.5,369,369.9,370.8,374.5,378.4,381.3,383.5,387.6,391.7,395.4,399.3,403.3,406.6,410.5,413.5,418.7,421.7,422.8,425.8,427.6,431,434.3,437.6,440.4,443.5,446.2,446.2,449.7,454.2,458.4,461.1,464,466.2,468.7,471.8,474.9,477.5,480,482.8,485.7,488.5,492,495.1,498.5,502.2,502.1,510,515,520.4,525.2,530.1,534.5,538.5,544.4,548.4,551.9,554.9,558.1,561.3,564.4,567,568.7,570.9,572.5,574.6,577.1,580.9,583.3,586.5) > 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] 80 > (np <- floor(n / par1)) [1] 20 > 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] [,12] [1,] 340.7 349.0 360.1 369.9 381.3 395.4 410.5 422.8 434.3 446.2 458.4 468.7 [2,] 343.5 351.4 364.7 370.8 383.5 399.3 413.5 425.8 437.6 446.2 461.1 471.8 [3,] 345.3 353.0 366.5 374.5 387.6 403.3 418.7 427.6 440.4 449.7 464.0 474.9 [4,] 346.9 355.0 369.0 378.4 391.7 406.6 421.7 431.0 443.5 454.2 466.2 477.5 [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [1,] 480.0 492.0 502.1 525.2 544.4 558.1 568.7 577.1 [2,] 482.8 495.1 510.0 530.1 548.4 561.3 570.9 580.9 [3,] 485.7 498.5 515.0 534.5 551.9 564.4 572.5 583.3 [4,] 488.5 502.2 520.4 538.5 554.9 567.0 574.6 586.5 > 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] 344.100 352.100 365.075 373.400 386.025 401.150 416.100 426.800 438.950 [10] 449.075 462.425 473.225 484.250 496.950 511.875 532.075 549.900 562.700 [19] 571.675 581.950 > arr.sd [1] 2.658320 2.537716 3.756217 3.882439 4.596647 4.858326 5.041164 3.429286 [9] 3.926406 3.794184 3.400368 3.811714 3.666515 4.392797 7.778335 5.725018 [17] 4.527693 3.851407 2.495830 3.964425 > arr.range [1] 6.2 6.0 8.9 8.5 10.4 11.2 11.2 8.2 9.2 8.0 7.8 8.8 8.5 10.2 18.3 [16] 13.3 10.5 8.9 5.9 9.4 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 2.379502 0.003759 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -1.2768 0.4339 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 5.048946 0.009632 > postscript(file="/var/wessaorg/rcomp/tmp/1dc6e1447845090.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/2zarh1447845090.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/31d7q1447845090.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/4s0rk1447845090.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/55d641447845090.tab") > > try(system("convert tmp/1dc6e1447845090.ps tmp/1dc6e1447845090.png",intern=TRUE)) character(0) > try(system("convert tmp/2zarh1447845090.ps tmp/2zarh1447845090.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.859 0.142 1.006