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(2443.6,2460.2,2448.2,2470.4,2484.7,2466.8,2487.9,2508.4,2510.5,2497.4,2532.5,2556.8,2561,2547.3,2541.5,2558.5,2587.9,2580.5,2579.6,2589.3,2595,2595.6,2588.8,2591.7,2601.7,2585.4,2573.3,2597.4,2600.6,2570.6,2569.4,2584.9,2608.8,2617.2,2621,2540.5,2554.5,2601.9,2623,2640.7,2640.7,2619.8,2624.2,2638.2,2645.7,2679.6,2669,2664.6,2663.3,2667.4,2653.2,2630.8,2626.6,2641.9,2625.8,2606,2594.4,2583.6,2588.7,2600.3,2579.5,2576.6,2597.8,2595.6,2599,2621.7,2645.6,2644.2,2625.6,2624.6,2596.2,2599.5,2584.1,2570.8,2555,2574.5,2576.7,2579,2588.7,2601.1,2575.7,2559.5,2561.1,2528.3,2514.7,2558.5,2553.3,2577.1,2566,2549.5,2527.8,2540.9,2534.2,2538,2559,2554.9,2575.5,2546.5,2561.6,2546.6,2502.9,2463.1,2472.6,2463.5,2446.3,2456.2,2471.5,2447.5,2428.6,2420.2,2414.9,2420.2,2423.8,2407,2388.7,2409.6,2392,2380.2,2423.3,2451.6,2440.8,2432.9,2413.6,2391.6,2358.1,2345.4,2384.4,2384.4,2384.4,2418.7,2420,2493.1,2493.1,2492.8) > 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] 134 > (np <- floor(n / par1)) [1] 11 > 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,] 2443.6 2561.0 2601.7 2554.5 2663.3 2579.5 2584.1 2514.7 2575.5 2428.6 [2,] 2460.2 2547.3 2585.4 2601.9 2667.4 2576.6 2570.8 2558.5 2546.5 2420.2 [3,] 2448.2 2541.5 2573.3 2623.0 2653.2 2597.8 2555.0 2553.3 2561.6 2414.9 [4,] 2470.4 2558.5 2597.4 2640.7 2630.8 2595.6 2574.5 2577.1 2546.6 2420.2 [5,] 2484.7 2587.9 2600.6 2640.7 2626.6 2599.0 2576.7 2566.0 2502.9 2423.8 [6,] 2466.8 2580.5 2570.6 2619.8 2641.9 2621.7 2579.0 2549.5 2463.1 2407.0 [7,] 2487.9 2579.6 2569.4 2624.2 2625.8 2645.6 2588.7 2527.8 2472.6 2388.7 [8,] 2508.4 2589.3 2584.9 2638.2 2606.0 2644.2 2601.1 2540.9 2463.5 2409.6 [9,] 2510.5 2595.0 2608.8 2645.7 2594.4 2625.6 2575.7 2534.2 2446.3 2392.0 [10,] 2497.4 2595.6 2617.2 2679.6 2583.6 2624.6 2559.5 2538.0 2456.2 2380.2 [11,] 2532.5 2588.8 2621.0 2669.0 2588.7 2596.2 2561.1 2559.0 2471.5 2423.3 [12,] 2556.8 2591.7 2540.5 2664.6 2600.3 2599.5 2528.3 2554.9 2447.5 2451.6 [,11] [1,] 2440.8 [2,] 2432.9 [3,] 2413.6 [4,] 2391.6 [5,] 2358.1 [6,] 2345.4 [7,] 2384.4 [8,] 2384.4 [9,] 2384.4 [10,] 2418.7 [11,] 2420.0 [12,] 2493.1 > 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] 2488.950 2576.392 2589.233 2633.492 2623.500 2608.825 2571.208 2547.825 [9] 2496.150 2413.342 2405.617 > arr.sd [1] 34.12806 19.18937 23.21494 33.37292 29.06801 23.03662 18.66160 17.41844 [9] 48.12334 19.57928 39.89550 > arr.range [1] 113.2 54.1 80.5 125.1 83.8 69.0 72.8 62.4 129.2 71.4 147.7 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 123.51100 -0.03767 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) 24.573 -2.717 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 471.2911 -0.1493 > postscript(file="/var/wessaorg/rcomp/tmp/1pf8i1438968494.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/2o55v1438968494.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/3puax1438968494.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/46hxv1438968494.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/5m68q1438968494.tab") > > try(system("convert tmp/1pf8i1438968494.ps tmp/1pf8i1438968494.png",intern=TRUE)) character(0) > try(system("convert tmp/2o55v1438968494.ps tmp/2o55v1438968494.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.918 0.172 1.092