R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 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(1.8,1.8,1.81,1.81,1.81,1.81,1.81,1.81,1.82,1.82,1.81,1.8,1.8,1.81,1.81,1.81,1.81,1.81,1.81,1.82,1.82,1.82,1.83,1.83,1.83,1.84,1.85,1.86,1.86,1.87,1.87,1.86,1.88,1.89,1.91,1.91,1.91,1.91,1.92,1.93,1.93,1.94,1.94,1.95,1.95,1.96,1.97,1.97,1.97,1.97,1.98,1.98,1.99,1.99,1.99,2,2,2.01,2.01,2.02,2.01,2.01,2.03,2.03,2.04,2.05,2.05,2.06,2.06,2.06,2.04,2.04,2.04,2.03,2.03,2.03,2.03,2.03,2.03,2.03,2.03,2.03,2.02,2.03,2.03,2.02,2.03,2.04,2.05,2.05,2.05,2.05,2.07,2.07,2.08,2.08) > 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] 96 > (np <- floor(n / par1)) [1] 8 > 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,] 1.80 1.80 1.83 1.91 1.97 2.01 2.04 2.03 [2,] 1.80 1.81 1.84 1.91 1.97 2.01 2.03 2.02 [3,] 1.81 1.81 1.85 1.92 1.98 2.03 2.03 2.03 [4,] 1.81 1.81 1.86 1.93 1.98 2.03 2.03 2.04 [5,] 1.81 1.81 1.86 1.93 1.99 2.04 2.03 2.05 [6,] 1.81 1.81 1.87 1.94 1.99 2.05 2.03 2.05 [7,] 1.81 1.81 1.87 1.94 1.99 2.05 2.03 2.05 [8,] 1.81 1.82 1.86 1.95 2.00 2.06 2.03 2.05 [9,] 1.82 1.82 1.88 1.95 2.00 2.06 2.03 2.07 [10,] 1.82 1.82 1.89 1.96 2.01 2.06 2.03 2.07 [11,] 1.81 1.83 1.91 1.97 2.01 2.04 2.02 2.08 [12,] 1.80 1.83 1.91 1.97 2.02 2.04 2.03 2.08 > 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] 1.809167 1.815000 1.869167 1.940000 1.992500 2.040000 2.030000 2.051667 > arr.sd [1] 0.006685579 0.009045340 0.025030285 0.020889319 0.016025548 0.017580981 [7] 0.004264014 0.019924098 > arr.range [1] 0.02 0.03 0.08 0.06 0.05 0.05 0.02 0.06 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean -0.01297 0.01436 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) -5.753 2.111 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean -0.03094 0.03972 > postscript(file="/var/wessaorg/rcomp/tmp/1lk641416760430.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/2ffuw1416760430.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/3128a1416760430.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/4t05b1416760430.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/5mlnw1416760430.tab") > > try(system("convert tmp/1lk641416760430.ps tmp/1lk641416760430.png",intern=TRUE)) character(0) > try(system("convert tmp/2ffuw1416760430.ps tmp/2ffuw1416760430.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.912 0.179 1.091