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(1069108,1059362,1049495,1029082,1231089,1220388,1069108,968521,978233,978233,989056,1008514,1069108,1049495,1079775,1129547,1412683,1412683,1352244,1291650,1341422,1401983,1412683,1442964,1533833,1473244,1473244,1564114,1816014,1836427,1785734,1664578,1755420,1755420,1765165,1816014,1856040,1876453,1876453,1937014,2169452,2229890,2239603,2088322,2169452,2139171,2078582,2209478,2239603,2188909,2199610,2269916,2532640,2663352,2663352,2602913,2693660,2602913,2552092,2744509,2774634,2703378,2884967,2956228,3168103,3308711,3289258,3278430,3359559,3349692,3228692,3410253,3470847,3410253,3662154,3783309,4065362,4176650,4146492,4085897,4136624,4197185,3995056,4156204,4257779,4216798,4479366,4570080,4953837,5024138,4933418,4984117,5014398,5044678,4852261,5033856,5134437,5033856,5326854,5417607,5811037,5871631,5891089,5992631,5992631,6032657,5851063,5941938,6002377,5891089,6214246,6274812,6678021,6749283,6849864,6940739,6950451,6961152,6779563,6961152) > 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] 120 > (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] [1,] 1069108 1069108 1533833 1856040 2239603 2774634 3470847 4257779 5134437 [2,] 1059362 1049495 1473244 1876453 2188909 2703378 3410253 4216798 5033856 [3,] 1049495 1079775 1473244 1876453 2199610 2884967 3662154 4479366 5326854 [4,] 1029082 1129547 1564114 1937014 2269916 2956228 3783309 4570080 5417607 [5,] 1231089 1412683 1816014 2169452 2532640 3168103 4065362 4953837 5811037 [6,] 1220388 1412683 1836427 2229890 2663352 3308711 4176650 5024138 5871631 [7,] 1069108 1352244 1785734 2239603 2663352 3289258 4146492 4933418 5891089 [8,] 968521 1291650 1664578 2088322 2602913 3278430 4085897 4984117 5992631 [9,] 978233 1341422 1755420 2169452 2693660 3359559 4136624 5014398 5992631 [10,] 978233 1401983 1755420 2139171 2602913 3349692 4197185 5044678 6032657 [11,] 989056 1412683 1765165 2078582 2552092 3228692 3995056 4852261 5851063 [12,] 1008514 1442964 1816014 2209478 2744509 3410253 4156204 5033856 5941938 [,10] [1,] 6002377 [2,] 5891089 [3,] 6214246 [4,] 6274812 [5,] 6678021 [6,] 6749283 [7,] 6849864 [8,] 6940739 [9,] 6950451 [10,] 6961152 [11,] 6779563 [12,] 6961152 > 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] 1054182 1283020 1686601 2072492 2496122 3142659 3940503 4780394 5691453 [10] 6604396 > arr.sd [1] 88032.11 154803.03 138591.49 146805.36 209587.10 246176.96 284877.65 [8] 312474.22 359709.27 397361.49 > arr.range [1] 262568 393469 363183 383563 555600 706875 786932 827880 998801 [10] 1070063 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 6.029e+04 5.299e-02 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Call: lm(formula = log(arr.sd) ~ log(arr.mean)) Coefficients: (Intercept) log(arr.mean) 1.1911 0.7465 > (lm2 <- lm(arr.range~arr.mean)) Call: lm(formula = arr.range ~ arr.mean) Coefficients: (Intercept) arr.mean 1.590e+05 1.453e-01 > postscript(file="/var/wessaorg/rcomp/tmp/1lagf1404903196.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/2lcnj1404903196.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/3sqk51404903196.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/4stk11404903196.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/5uuqj1404903196.tab") > > try(system("convert tmp/1lagf1404903196.ps tmp/1lagf1404903196.png",intern=TRUE)) character(0) > try(system("convert tmp/2lcnj1404903196.ps tmp/2lcnj1404903196.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.902 0.152 1.040