R version 2.9.0 (2009-04-17) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(26.663 + ,23.598 + ,26.931 + ,24.740 + ,25.806 + ,24.364 + ,24.477 + ,23.901 + ,23.175 + ,23.227 + ,21.672 + ,21.870 + ,21.439 + ,21.089 + ,23.709 + ,21.669 + ,21.752 + ,20.761 + ,23.479 + ,23.824 + ,23.105 + ,23.110 + ,21.759 + ,22.073 + ,21.937 + ,20.035 + ,23.590 + ,21.672 + ,22.222 + ,22.123 + ,23.950 + ,23.504 + ,22.238 + ,23.142 + ,21.059 + ,21.573 + ,21.548 + ,20.000 + ,22.424 + ,20.615 + ,21.761 + ,22.874 + ,24.104 + ,23.748 + ,23.262 + ,22.907 + ,21.519 + ,22.025 + ,22.604 + ,20.894 + ,24.677 + ,23.673 + ,25.320 + ,23.583 + ,24.671 + ,24.454 + ,24.122 + ,24.252 + ,22.084 + ,22.991 + ,23.287 + ,23.049 + ,25.076 + ,24.037 + ,24.430 + ,24.667 + ,26.451 + ,25.618 + ,25.014 + ,25.110 + ,22.964 + ,23.981 + ,23.798 + ,22.270 + ,24.775 + ,22.646 + ,23.988 + ,24.737 + ,26.276 + ,25.816 + ,25.210 + ,25.199 + ,23.162 + ,24.707 + ,24.364 + ,22.644 + ,25.565 + ,24.062 + ,25.431 + ,24.635 + ,27.009 + ,26.606 + ,26.268 + ,26.462 + ,25.246 + ,25.180 + ,24.657 + ,23.304 + ,26.982 + ,26.199 + ,27.210 + ,26.122 + ,26.706 + ,26.878 + ,26.152 + ,26.379 + ,24.712 + ,25.688 + ,24.990 + ,24.239 + ,26.721 + ,23.475 + ,24.767 + ,26.219 + ,28.361 + ,28.599 + ,27.914 + ,27.784 + ,25.693 + ,26.881 + ,26.217 + ,24.218 + ,27.914 + ,26.975 + ,28.527 + ,27.139 + ,28.982 + ,28.169 + ,28.056 + ,29.136 + ,26.291 + ,26.987 + ,26.589 + ,24.848 + ,27.543 + ,26.896 + ,28.878 + ,27.390 + ,28.065 + ,28.141 + ,29.048 + ,28.484 + ,26.634 + ,27.735 + ,27.132 + ,24.924 + ,28.963 + ,26.589 + ,27.931 + ,28.009 + ,29.229 + ,28.759 + ,28.405 + ,27.945 + ,25.912 + ,26.619 + ,26.076 + ,25.286 + ,27.660 + ,25.951 + ,26.398 + ,25.565 + ,28.865 + ,30.000 + ,29.261 + ,29.012 + ,26.992 + ,27.897) > ylimmax = '' > ylimmin = '' > main = 'maandelijkse geboortes new york' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > geomean <- function(x) { + return(exp(mean(log(x)))) + } > harmean <- function(x) { + return(1/mean(1/x)) + } > quamean <- function(x) { + return(sqrt(mean(x*x))) + } > winmean <- function(x) { + x <-sort(x[!is.na(x)]) + n<-length(x) + denom <- 3 + nodenom <- n/denom + if (nodenom>40) denom <- n/40 + sqrtn = sqrt(n) + roundnodenom = floor(nodenom) + win <- array(NA,dim=c(roundnodenom,2)) + for (j in 1:roundnodenom) { + win[j,1] <- (j*x[j+1]+sum(x[(j+1):(n-j)])+j*x[n-j])/n + win[j,2] <- sd(c(rep(x[j+1],j),x[(j+1):(n-j)],rep(x[n-j],j)))/sqrtn + } + return(win) + } > trimean <- function(x) { + x <-sort(x[!is.na(x)]) + n<-length(x) + denom <- 3 + nodenom <- n/denom + if (nodenom>40) denom <- n/40 + sqrtn = sqrt(n) + roundnodenom = floor(nodenom) + tri <- array(NA,dim=c(roundnodenom,2)) + for (j in 1:roundnodenom) { + tri[j,1] <- mean(x,trim=j/n) + tri[j,2] <- sd(x[(j+1):(n-j)]) / sqrt(n-j*2) + } + return(tri) + } > midrange <- function(x) { + return((max(x)+min(x))/2) + } > q1 <- function(data,n,p,i,f) { + np <- n*p; + i <<- floor(np) + f <<- np - i + qvalue <- (1-f)*data[i] + f*data[i+1] + } > q2 <- function(data,n,p,i,f) { + np <- (n+1)*p + i <<- floor(np) + f <<- np - i + qvalue <- (1-f)*data[i] + f*data[i+1] + } > q3 <- function(data,n,p,i,f) { + np <- n*p + i <<- floor(np) + f <<- np - i + if (f==0) { + qvalue <- data[i] + } else { + qvalue <- data[i+1] + } + } > q4 <- function(data,n,p,i,f) { + np <- n*p + i <<- floor(np) + f <<- np - i + if (f==0) { + qvalue <- (data[i]+data[i+1])/2 + } else { + qvalue <- data[i+1] + } + } > q5 <- function(data,n,p,i,f) { + np <- (n-1)*p + i <<- floor(np) + f <<- np - i + if (f==0) { + qvalue <- data[i+1] + } else { + qvalue <- data[i+1] + f*(data[i+2]-data[i+1]) + } + } > q6 <- function(data,n,p,i,f) { + np <- n*p+0.5 + i <<- floor(np) + f <<- np - i + qvalue <- data[i] + } > q7 <- function(data,n,p,i,f) { + np <- (n+1)*p + i <<- floor(np) + f <<- np - i + if (f==0) { + qvalue <- data[i] + } else { + qvalue <- f*data[i] + (1-f)*data[i+1] + } + } > q8 <- function(data,n,p,i,f) { + np <- (n+1)*p + i <<- floor(np) + f <<- np - i + if (f==0) { + qvalue <- data[i] + } else { + if (f == 0.5) { + qvalue <- (data[i]+data[i+1])/2 + } else { + if (f < 0.5) { + qvalue <- data[i] + } else { + qvalue <- data[i+1] + } + } + } + } > midmean <- function(x,def) { + x <-sort(x[!is.na(x)]) + n<-length(x) + if (def==1) { + qvalue1 <- q1(x,n,0.25,i,f) + qvalue3 <- q1(x,n,0.75,i,f) + } + if (def==2) { + qvalue1 <- q2(x,n,0.25,i,f) + qvalue3 <- q2(x,n,0.75,i,f) + } + if (def==3) { + qvalue1 <- q3(x,n,0.25,i,f) + qvalue3 <- q3(x,n,0.75,i,f) + } + if (def==4) { + qvalue1 <- q4(x,n,0.25,i,f) + qvalue3 <- q4(x,n,0.75,i,f) + } + if (def==5) { + qvalue1 <- q5(x,n,0.25,i,f) + qvalue3 <- q5(x,n,0.75,i,f) + } + if (def==6) { + qvalue1 <- q6(x,n,0.25,i,f) + qvalue3 <- q6(x,n,0.75,i,f) + } + if (def==7) { + qvalue1 <- q7(x,n,0.25,i,f) + qvalue3 <- q7(x,n,0.75,i,f) + } + if (def==8) { + qvalue1 <- q8(x,n,0.25,i,f) + qvalue3 <- q8(x,n,0.75,i,f) + } + midm <- 0 + myn <- 0 + roundno4 <- round(n/4) + round3no4 <- round(3*n/4) + for (i in 1:n) { + if ((x[i]>=qvalue1) & (x[i]<=qvalue3)){ + midm = midm + x[i] + myn = myn + 1 + } + } + midm = midm / myn + return(midm) + } > (arm <- mean(x)) [1] 25.05931 > sqrtn <- sqrt(length(x)) > (armse <- sd(x) / sqrtn) [1] 0.1788986 > (armose <- arm / armse) [1] 140.0755 > (geo <- geomean(x)) [1] 24.95177 > (har <- harmean(x)) [1] 24.84346 > (qua <- quamean(x)) [1] 25.16573 > (win <- winmean(x)) [,1] [,2] [1,] 25.05512 0.17818870 [2,] 25.06164 0.17703305 [3,] 25.06259 0.17641478 [4,] 25.06366 0.17567142 [5,] 25.06750 0.17484020 [6,] 25.06750 0.17454923 [7,] 25.08129 0.17252532 [8,] 25.08105 0.17150666 [9,] 25.08191 0.17122182 [10,] 25.07709 0.17021210 [11,] 25.07290 0.16810704 [12,] 25.06797 0.16743996 [13,] 25.06464 0.16703022 [14,] 25.06473 0.16542352 [15,] 25.06142 0.16487567 [16,] 25.04333 0.16270507 [17,] 25.05152 0.16106079 [18,] 25.05056 0.15928703 [19,] 25.05949 0.15801686 [20,] 25.05961 0.15672935 [21,] 25.05299 0.15567667 [22,] 25.05626 0.15489163 [23,] 25.06749 0.15311004 [24,] 25.06977 0.15285608 [25,] 25.07201 0.15204755 [26,] 25.07835 0.14751472 [27,] 25.09940 0.14358501 [28,] 25.09357 0.14152695 [29,] 25.07372 0.13932262 [30,] 25.08711 0.13228240 [31,] 25.05999 0.12827239 [32,] 25.05732 0.12583741 [33,] 25.06125 0.12517444 [34,] 25.04810 0.12157985 [35,] 25.05622 0.12009600 [36,] 25.05622 0.11988844 [37,] 25.06217 0.11909946 [38,] 25.06511 0.11851077 [39,] 25.05791 0.11723910 [40,] 25.06196 0.11525791 [41,] 25.06684 0.11409754 [42,] 25.07234 0.11343557 [43,] 25.03651 0.10925269 [44,] 25.07736 0.10470851 [45,] 25.06692 0.10354225 [46,] 25.06582 0.10218336 [47,] 25.08373 0.09979052 [48,] 25.08201 0.09926865 [49,] 25.07939 0.09860351 [50,] 25.10171 0.09661100 [51,] 25.07408 0.09212539 [52,] 25.08275 0.09075098 [53,] 25.08180 0.08786147 [54,] 25.08405 0.08658434 [55,] 25.08045 0.08183142 [56,] 25.09179 0.07998534 > (tri <- trimean(x)) [,1] [,2] [1,] 25.06002 0.17594651 [2,] 25.06505 0.17353454 [3,] 25.06681 0.17158287 [4,] 25.06829 0.16971734 [5,] 25.06953 0.16792627 [6,] 25.06996 0.16619653 [7,] 25.07041 0.16438863 [8,] 25.06869 0.16280998 [9,] 25.06696 0.16127001 [10,] 25.06507 0.15964292 [11,] 25.06369 0.15802131 [12,] 25.06272 0.15654089 [13,] 25.06220 0.15501308 [14,] 25.06197 0.15339722 [15,] 25.06173 0.15182096 [16,] 25.06176 0.15016015 [17,] 25.06320 0.14857879 [18,] 25.06408 0.14701968 [19,] 25.06505 0.14549047 [20,] 25.06543 0.14393729 [21,] 25.06582 0.14235472 [22,] 25.06665 0.14071271 [23,] 25.06730 0.13897670 [24,] 25.06728 0.13722989 [25,] 25.06714 0.13532116 [26,] 25.06685 0.13328420 [27,] 25.06620 0.13145703 [28,] 25.06436 0.12979166 [29,] 25.06276 0.12812634 [30,] 25.06218 0.12647187 [31,] 25.06086 0.12526081 [32,] 25.06090 0.12425085 [33,] 25.06109 0.12331540 [34,] 25.06108 0.12230338 [35,] 25.06173 0.12146212 [36,] 25.06201 0.12061962 [37,] 25.06230 0.11965968 [38,] 25.06230 0.11861952 [39,] 25.06217 0.11746884 [40,] 25.06237 0.11625664 [41,] 25.06240 0.11504160 [42,] 25.06218 0.11374042 [43,] 25.06168 0.11228879 [44,] 25.06291 0.11102554 [45,] 25.06221 0.11000811 [46,] 25.06197 0.10891348 [47,] 25.06178 0.10774839 [48,] 25.06069 0.10661225 [49,] 25.05963 0.10529745 [50,] 25.05863 0.10378851 [51,] 25.05863 0.10220775 [52,] 25.05553 0.10086913 [53,] 25.05411 0.09939906 [54,] 25.05265 0.09797791 [55,] 25.05097 0.09638644 [56,] 25.04936 0.09509673 > (midr <- midrange(x)) [1] 25 > midm <- array(NA,dim=8) > for (j in 1:8) midm[j] <- midmean(x,j) > midm [1] 25.04100 25.06218 25.04100 25.06218 25.06218 25.04100 25.06218 25.06240 > postscript(file="/var/www/html/rcomp/tmp/1uq621271864149.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > lb <- win[,1] - 2*win[,2] > ub <- win[,1] + 2*win[,2] > if ((ylimmin == '') | (ylimmax == '')) plot(win[,1],type='b',main=main, xlab='j', pch=19, ylab='Winsorized Mean(j/n)', ylim=c(min(lb),max(ub))) else plot(win[,1],type='l',main=main, xlab='j', pch=19, ylab='Winsorized Mean(j/n)', ylim=c(ylimmin,ylimmax)) > lines(ub,lty=3) > lines(lb,lty=3) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/25in51271864149.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > lb <- tri[,1] - 2*tri[,2] > ub <- tri[,1] + 2*tri[,2] > if ((ylimmin == '') | (ylimmax == '')) plot(tri[,1],type='b',main=main, xlab='j', pch=19, ylab='Trimmed Mean(j/n)', ylim=c(min(lb),max(ub))) else plot(tri[,1],type='l',main=main, xlab='j', pch=19, ylab='Trimmed Mean(j/n)', ylim=c(ylimmin,ylimmax)) > lines(ub,lty=3) > lines(lb,lty=3) > grid() > dev.off() null device 1 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Central Tendency - Ungrouped Data',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Measure',header=TRUE) > a<-table.element(a,'Value',header=TRUE) > a<-table.element(a,'S.E.',header=TRUE) > a<-table.element(a,'Value/S.E.',header=TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,hyperlink('http://www.xycoon.com/arithmetic_mean.htm', 'Arithmetic Mean', 'click to view the definition of the Arithmetic Mean'),header=TRUE) > a<-table.element(a,arm) > a<-table.element(a,hyperlink('http://www.xycoon.com/arithmetic_mean_standard_error.htm', armse, 'click to view the definition of the Standard Error of the Arithmetic Mean')) > a<-table.element(a,armose) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,hyperlink('http://www.xycoon.com/geometric_mean.htm', 'Geometric Mean', 'click to view the definition of the Geometric Mean'),header=TRUE) > a<-table.element(a,geo) > a<-table.element(a,'') > a<-table.element(a,'') > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,hyperlink('http://www.xycoon.com/harmonic_mean.htm', 'Harmonic Mean', 'click to view the definition of the Harmonic Mean'),header=TRUE) > a<-table.element(a,har) > a<-table.element(a,'') > a<-table.element(a,'') > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,hyperlink('http://www.xycoon.com/quadratic_mean.htm', 'Quadratic Mean', 'click to view the definition of the Quadratic Mean'),header=TRUE) > a<-table.element(a,qua) > a<-table.element(a,'') > a<-table.element(a,'') > a<-table.row.end(a) > for (j in 1:length(win[,1])) { + a<-table.row.start(a) + mylabel <- paste('Winsorized Mean (',j) + mylabel <- paste(mylabel,'/') + mylabel <- paste(mylabel,length(win[,1])) + mylabel <- paste(mylabel,')') + a<-table.element(a,hyperlink('http://www.xycoon.com/winsorized_mean.htm', mylabel, 'click to view the definition of the Winsorized Mean'),header=TRUE) + a<-table.element(a,win[j,1]) + a<-table.element(a,win[j,2]) + a<-table.element(a,win[j,1]/win[j,2]) + a<-table.row.end(a) + } > for (j in 1:length(tri[,1])) { + a<-table.row.start(a) + mylabel <- paste('Trimmed Mean (',j) + mylabel <- paste(mylabel,'/') + mylabel <- paste(mylabel,length(tri[,1])) + mylabel <- paste(mylabel,')') + a<-table.element(a,hyperlink('http://www.xycoon.com/arithmetic_mean.htm', mylabel, 'click to view the definition of the Trimmed Mean'),header=TRUE) + a<-table.element(a,tri[j,1]) + a<-table.element(a,tri[j,2]) + a<-table.element(a,tri[j,1]/tri[j,2]) + a<-table.row.end(a) + } > a<-table.row.start(a) > a<-table.element(a,hyperlink('http://www.xycoon.com/median_1.htm', 'Median', 'click to view the definition of the Median'),header=TRUE) > a<-table.element(a,median(x)) > a<-table.element(a,'') > a<-table.element(a,'') > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,hyperlink('http://www.xycoon.com/midrange.htm', 'Midrange', 'click to view the definition of the Midrange'),header=TRUE) > a<-table.element(a,midr) > a<-table.element(a,'') > a<-table.element(a,'') > a<-table.row.end(a) > a<-table.row.start(a) > mymid <- hyperlink('http://www.xycoon.com/midmean.htm', 'Midmean', 'click to view the definition of the Midmean') > mylabel <- paste(mymid,hyperlink('http://www.xycoon.com/method_1.htm','Weighted Average at Xnp',''),sep=' - ') > a<-table.element(a,mylabel,header=TRUE) > a<-table.element(a,midm[1]) > a<-table.element(a,'') > a<-table.element(a,'') > a<-table.row.end(a) > a<-table.row.start(a) > mymid <- hyperlink('http://www.xycoon.com/midmean.htm', 'Midmean', 'click to view the definition of the Midmean') > mylabel <- paste(mymid,hyperlink('http://www.xycoon.com/method_2.htm','Weighted Average at X(n+1)p',''),sep=' - ') > a<-table.element(a,mylabel,header=TRUE) > a<-table.element(a,midm[2]) > a<-table.element(a,'') > a<-table.element(a,'') > a<-table.row.end(a) > a<-table.row.start(a) > mymid <- hyperlink('http://www.xycoon.com/midmean.htm', 'Midmean', 'click to view the definition of the Midmean') > mylabel <- paste(mymid,hyperlink('http://www.xycoon.com/method_3.htm','Empirical Distribution Function',''),sep=' - ') > a<-table.element(a,mylabel,header=TRUE) > a<-table.element(a,midm[3]) > a<-table.element(a,'') > a<-table.element(a,'') > a<-table.row.end(a) > a<-table.row.start(a) > mymid <- hyperlink('http://www.xycoon.com/midmean.htm', 'Midmean', 'click to view the definition of the Midmean') > mylabel <- paste(mymid,hyperlink('http://www.xycoon.com/method_4.htm','Empirical Distribution Function - Averaging',''),sep=' - ') > a<-table.element(a,mylabel,header=TRUE) > a<-table.element(a,midm[4]) > a<-table.element(a,'') > a<-table.element(a,'') > a<-table.row.end(a) > a<-table.row.start(a) > mymid <- hyperlink('http://www.xycoon.com/midmean.htm', 'Midmean', 'click to view the definition of the Midmean') > mylabel <- paste(mymid,hyperlink('http://www.xycoon.com/method_5.htm','Empirical Distribution Function - Interpolation',''),sep=' - ') > a<-table.element(a,mylabel,header=TRUE) > a<-table.element(a,midm[5]) > a<-table.element(a,'') > a<-table.element(a,'') > a<-table.row.end(a) > a<-table.row.start(a) > mymid <- hyperlink('http://www.xycoon.com/midmean.htm', 'Midmean', 'click to view the definition of the Midmean') > mylabel <- paste(mymid,hyperlink('http://www.xycoon.com/method_6.htm','Closest Observation',''),sep=' - ') > a<-table.element(a,mylabel,header=TRUE) > a<-table.element(a,midm[6]) > a<-table.element(a,'') > a<-table.element(a,'') > a<-table.row.end(a) > a<-table.row.start(a) > mymid <- hyperlink('http://www.xycoon.com/midmean.htm', 'Midmean', 'click to view the definition of the Midmean') > mylabel <- paste(mymid,hyperlink('http://www.xycoon.com/method_7.htm','True Basic - Statistics Graphics Toolkit',''),sep=' - ') > a<-table.element(a,mylabel,header=TRUE) > a<-table.element(a,midm[7]) > a<-table.element(a,'') > a<-table.element(a,'') > a<-table.row.end(a) > a<-table.row.start(a) > mymid <- hyperlink('http://www.xycoon.com/midmean.htm', 'Midmean', 'click to view the definition of the Midmean') > mylabel <- paste(mymid,hyperlink('http://www.xycoon.com/method_8.htm','MS Excel (old versions)',''),sep=' - ') > a<-table.element(a,mylabel,header=TRUE) > a<-table.element(a,midm[8]) > a<-table.element(a,'') > a<-table.element(a,'') > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Number of observations',header=TRUE) > a<-table.element(a,length(x)) > a<-table.element(a,'') > a<-table.element(a,'') > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/3etx11271864149.tab") > > try(system("convert tmp/1uq621271864149.ps tmp/1uq621271864149.png",intern=TRUE)) character(0) > try(system("convert tmp/25in51271864149.ps tmp/25in51271864149.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.881 0.337 2.885