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(982800,946400,1001000,800800,1037400,1019200,1092000,1128400,1255800,1092000,1037400,1292200,1092000,819000,964600,728000,1019200,837200,1110200,1001000,1055600,1183000,1164800,1383200,1001000,837200,928200,673400,964600,746200,1055600,1001000,891800,1274000,1146600,1310400,982800,910000,819000,673400,891800,800800,1092000,1055600,910000,1219400,1128400,1456000,1164800,709800,709800,709800,837200,837200,1128400,1037400,928200,1164800,1073800,1547000,1219400,709800,746200,618800,855400,982800,1237600,1219400,982800,1146600,1019200,1456000,1110200,891800,800800,600600,891800,1073800,1255800,1183000,873600,1255800,982800,1510600,1255800,910000,837200,564200,891800,855400,1292200,1292200,982800,1274000,946400,1474200,1255800,928200,709800,491400,964600,928200,1219400,1401400,1037400,1164800,873600,1510600) > 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] 108 > (np <- floor(n / par1)) [1] 9 > 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] [1,] 982800 1092000 1001000 982800 1164800 1219400 1110200 1255800 1255800 [2,] 946400 819000 837200 910000 709800 709800 891800 910000 928200 [3,] 1001000 964600 928200 819000 709800 746200 800800 837200 709800 [4,] 800800 728000 673400 673400 709800 618800 600600 564200 491400 [5,] 1037400 1019200 964600 891800 837200 855400 891800 891800 964600 [6,] 1019200 837200 746200 800800 837200 982800 1073800 855400 928200 [7,] 1092000 1110200 1055600 1092000 1128400 1237600 1255800 1292200 1219400 [8,] 1128400 1001000 1001000 1055600 1037400 1219400 1183000 1292200 1401400 [9,] 1255800 1055600 891800 910000 928200 982800 873600 982800 1037400 [10,] 1092000 1183000 1274000 1219400 1164800 1146600 1255800 1274000 1164800 [11,] 1037400 1164800 1146600 1128400 1073800 1019200 982800 946400 873600 [12,] 1292200 1383200 1310400 1456000 1547000 1456000 1510600 1474200 1510600 > 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] 1057116.7 1029816.7 985833.3 994933.3 987350.0 1016166.7 1035883.3 [8] 1048016.7 1040433.3 > arr.sd [1] 131804.9 179745.5 192897.1 211298.7 249681.5 251329.4 246077.6 264365.5 [9] 288377.0 > arr.range [1] 491400 655200 637000 782600 837200 837200 910000 910000 1019200 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 3.337e+05 -1.074e-01 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) 30.232 -1.296 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 5.589e+05 2.229e-01 > postscript(file="/var/wessaorg/rcomp/tmp/1j7171439127919.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/2jc6m1439127919.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/3u44i1439127919.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/4q9uc1439127919.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/5y2lx1439127919.tab") > > try(system("convert tmp/1j7171439127919.ps tmp/1j7171439127919.png",intern=TRUE)) character(0) > try(system("convert tmp/2jc6m1439127919.ps tmp/2jc6m1439127919.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.895 0.172 1.074