 | :: Variability - Free Statistics Software (Calculator) :: | |
|
All rights reserved. The non-commercial (academic) use of this software is free of charge. The only thing that is asked in return is to cite this software when results are used in publications.
This free online software (calculator) computes the following statistics: absolute range, relative range, variance, standard error, coefficient of variation, mean squared error, mean absolute deviation, median absolute deviation, mean squared deviation, interquartile difference, semi interquartile difference, coefficient of quartile variation, number of pairs of observations, squared differences between observations, mean absolute differences between observations, Gini mean difference, Leik measure of dispersion, index of diversity, index of qualitative variation, and coefficient of dispersion.
Click here to edit the underlying code of this R Module.Enter (or paste) your data delimited by hard returns. Click here to edit the underlying code of this R Module.
| Source code of R module | | 1 | num <- 50 | | 2 | res <- array(NA,dim=c(num,3)) | | 3 | q1 <- function(data,n,p,i,f) { | | 4 | np <- n*p; | | 5 | i <<- floor(np) | | 6 | f <<- np - i | | 7 | qvalue <- (1-f)*data[i] + f*data[i+1] | | 8 | } | | 9 | q2 <- function(data,n,p,i,f) { | | 10 | np <- (n+1)*p | | 11 | i <<- floor(np) | | 12 | f <<- np - i | | 13 | qvalue <- (1-f)*data[i] + f*data[i+1] | | 14 | } | | 15 | q3 <- function(data,n,p,i,f) { | | 16 | np <- n*p | | 17 | i <<- floor(np) | | 18 | f <<- np - i | | 19 | if (f==0) { | | 20 | qvalue <- data[i] | | 21 | } else { | | 22 | qvalue <- data[i+1] | | 23 | } | | 24 | } | | 25 | q4 <- function(data,n,p,i,f) { | | 26 | np <- n*p | | 27 | i <<- floor(np) | | 28 | f <<- np - i | | 29 | if (f==0) { | | 30 | qvalue <- (data[i]+data[i+1])/2 | | 31 | } else { | | 32 | qvalue <- data[i+1] | | 33 | } | | 34 | } | | 35 | q5 <- function(data,n,p,i,f) { | | 36 | np <- (n-1)*p | | 37 | i <<- floor(np) | | 38 | f <<- np - i | | 39 | if (f==0) { | | 40 | qvalue <- data[i+1] | | 41 | } else { | | 42 | qvalue <- data[i+1] + f*(data[i+2]-data[i+1]) | | 43 | } | | 44 | } | | 45 | q6 <- function(data,n,p,i,f) { | | 46 | np <- n*p+0.5 | | 47 | i <<- floor(np) | | 48 | f <<- np - i | | 49 | qvalue <- data[i] | | 50 | } | | 51 | q7 <- function(data,n,p,i,f) { | | 52 | np <- (n+1)*p | | 53 | i <<- floor(np) | | 54 | f <<- np - i | | 55 | if (f==0) { | | 56 | qvalue <- data[i] | | 57 | } else { | | 58 | qvalue <- f*data[i] + (1-f)*data[i+1] | | 59 | } | | 60 | } | | 61 | q8 <- function(data,n,p,i,f) { | | 62 | np <- (n+1)*p | | 63 | i <<- floor(np) | | 64 | f <<- np - i | | 65 | if (f==0) { | | 66 | qvalue <- data[i] | | 67 | } else { | | 68 | if (f == 0.5) { | | 69 | qvalue <- (data[i]+data[i+1])/2 | | 70 | } else { | | 71 | if (f < 0.5) { | | 72 | qvalue <- data[i] | | 73 | } else { | | 74 | qvalue <- data[i+1] | | 75 | } | | 76 | } | | 77 | } | | 78 | } | | 79 | iqd <- function(x,def) { | | 80 | x <-sort(x[!is.na(x)]) | | 81 | n<-length(x) | | 82 | if (def==1) { | | 83 | qvalue1 <- q1(x,n,0.25,i,f) | | 84 | qvalue3 <- q1(x,n,0.75,i,f) | | 85 | } | | 86 | if (def==2) { | | 87 | qvalue1 <- q2(x,n,0.25,i,f) | | 88 | qvalue3 <- q2(x,n,0.75,i,f) | | 89 | } | | 90 | if (def==3) { | | 91 | qvalue1 <- q3(x,n,0.25,i,f) | | 92 | qvalue3 <- q3(x,n,0.75,i,f) | | 93 | } | | 94 | if (def==4) { | | 95 | qvalue1 <- q4(x,n,0.25,i,f) | | 96 | qvalue3 <- q4(x,n,0.75,i,f) | | 97 | } | | 98 | if (def==5) { | | 99 | qvalue1 <- q5(x,n,0.25,i,f) | | 100 | qvalue3 <- q5(x,n,0.75,i,f) | | 101 | } | | 102 | if (def==6) { | | 103 | qvalue1 <- q6(x,n,0.25,i,f) | | 104 | qvalue3 <- q6(x,n,0.75,i,f) | | 105 | } | | 106 | if (def==7) { | | 107 | qvalue1 <- q7(x,n,0.25,i,f) | | 108 | qvalue3 <- q7(x,n,0.75,i,f) | | 109 | } | | 110 | if (def==8) { | | 111 | qvalue1 <- q8(x,n,0.25,i,f) | | 112 | qvalue3 <- q8(x,n,0.75,i,f) | | 113 | } | | 114 | iqdiff <- qvalue3 - qvalue1 | | 115 | return(c(iqdiff,iqdiff/2,iqdiff/(qvalue3 + qvalue1))) | | 116 | } | | 117 | range <- max(x) - min(x) | | 118 | lx <- length(x) | | 119 | biasf <- (lx-1)/lx | | 120 | varx <- var(x) | | 121 | bvarx <- varx*biasf | | 122 | sdx <- sqrt(varx) | | 123 | mx <- mean(x) | | 124 | bsdx <- sqrt(bvarx) | | 125 | x2 <- x*x | | 126 | mse0 <- sum(x2)/lx | | 127 | xmm <- x-mx | | 128 | xmm2 <- xmm*xmm | | 129 | msem <- sum(xmm2)/lx | | 130 | axmm <- abs(x - mx) | | 131 | medx <- median(x) | | 132 | axmmed <- abs(x - medx) | | 133 | xmmed <- x - medx | | 134 | xmmed2 <- xmmed*xmmed | | 135 | msemed <- sum(xmmed2)/lx | | 136 | qarr <- array(NA,dim=c(8,3)) | | 137 | for (j in 1:8) { | | 138 | qarr[j,] <- iqd(x,j) | | 139 | } | | 140 | sdpo <- 0 | | 141 | adpo <- 0 | | 142 | for (i in 1:(lx-1)) { | | 143 | for (j in (i+1):lx) { | | 144 | ldi <- x[i]-x[j] | | 145 | aldi <- abs(ldi) | | 146 | sdpo = sdpo + ldi * ldi | | 147 | adpo = adpo + aldi | | 148 | } | | 149 | } | | 150 | denom <- (lx*(lx-1)/2) | | 151 | sdpo = sdpo / denom | | 152 | adpo = adpo / denom | | 153 | gmd <- 0 | | 154 | for (i in 1:lx) { | | 155 | for (j in 1:lx) { | | 156 | ldi <- abs(x[i]-x[j]) | | 157 | gmd = gmd + ldi | | 158 | } | | 159 | } | | 160 | gmd <- gmd / (lx*(lx-1)) | | 161 | sumx <- sum(x) | | 162 | pk <- x / sumx | | 163 | ck <- cumsum(pk) | | 164 | dk <- array(NA,dim=lx) | | 165 | for (i in 1:lx) { | | 166 | if (ck[i] <= 0.5) dk[i] <- ck[i] else dk[i] <- 1 - ck[i] | | 167 | } | | 168 | bigd <- sum(dk) * 2 / (lx-1) | | 169 | iod <- 1 - sum(pk*pk) | | 170 | res[1,] <- c("Absolute range","http://www.xycoon.com/absolute.htm", range) | | 171 | res[2,] <- c("Relative range (unbiased)","http://www.xycoon.com/relative.htm", range/sd(x)) | | 172 | res[3,] <- c("Relative range (biased)","http://www.xycoon.com/relative.htm", range/sqrt(varx*biasf)) | | 173 | res[4,] <- c("Variance (unbiased)","http://www.xycoon.com/unbiased.htm", varx) | | 174 | res[5,] <- c("Variance (biased)","http://www.xycoon.com/biased.htm", bvarx) | | 175 | res[6,] <- c("Standard Deviation (unbiased)","http://www.xycoon.com/unbiased1.htm", sdx) | | 176 | res[7,] <- c("Standard Deviation (biased)","http://www.xycoon.com/biased1.htm", bsdx) | | 177 | res[8,] <- c("Coefficient of Variation (unbiased)","http://www.xycoon.com/variation.htm", sdx/mx) | | 178 | res[9,] <- c("Coefficient of Variation (biased)","http://www.xycoon.com/variation.htm", bsdx/mx) | | 179 | res[10,] <- c("Mean Squared Error (MSE versus 0)","http://www.xycoon.com/mse.htm", mse0) | | 180 | res[11,] <- c("Mean Squared Error (MSE versus Mean)","http://www.xycoon.com/mse.htm", msem) | | 181 | res[12,] <- c("Mean Absolute Deviation from Mean (MAD Mean)", "http://www.xycoon.com/mean2.htm", sum(axmm)/lx) | | 182 | res[13,] <- c("Mean Absolute Deviation from Median (MAD Median)", "http://www.xycoon.com/median1.htm", sum(axmmed)/lx) | | 183 | res[14,] <- c("Median Absolute Deviation from Mean", "http://www.xycoon.com/mean3.htm", median(axmm)) | | 184 | res[15,] <- c("Median Absolute Deviation from Median", "http://www.xycoon.com/median2.htm", median(axmmed)) | | 185 | res[16,] <- c("Mean Squared Deviation from Mean", "http://www.xycoon.com/mean1.htm", msem) | | 186 | res[17,] <- c("Mean Squared Deviation from Median", "http://www.xycoon.com/median.htm", msemed) | | 187 | load(file="createtable") | | 188 | mylink1 <- hyperlink("http://www.xycoon.com/difference.htm","Interquartile Difference","") | | 189 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_1.htm","(Weighted Average at Xnp)",""),sep=" ") | | 190 | res[18,] <- c("", mylink2, qarr[1,1]) | | 191 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_2.htm","(Weighted Average at X(n+1)p)",""),sep=" ") | | 192 | res[19,] <- c("", mylink2, qarr[2,1]) | | 193 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_3.htm","(Empirical Distribution Function)",""),sep=" ") | | 194 | res[20,] <- c("", mylink2, qarr[3,1]) | | 195 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_4.htm","(Empirical Distribution Function - Averaging)",""),sep=" ") | | 196 | res[21,] <- c("", mylink2, qarr[4,1]) | | 197 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_5.htm","(Empirical Distribution Function - Interpolation)",""),sep=" ") | | 198 | res[22,] <- c("", mylink2, qarr[5,1]) | | 199 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_6.htm","(Closest Observation)",""),sep=" ") | | 200 | res[23,] <- c("", mylink2, qarr[6,1]) | | 201 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_7.htm","(True Basic - Statistics Graphics Toolkit)",""),sep=" ") | | 202 | res[24,] <- c("", mylink2, qarr[7,1]) | | 203 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_8.htm","(MS Excel (old versions))",""),sep=" ") | | 204 | res[25,] <- c("", mylink2, qarr[8,1]) | | 205 | mylink1 <- hyperlink("http://www.xycoon.com/deviation.htm","Semi Interquartile Difference","") | | 206 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_1.htm","(Weighted Average at Xnp)",""),sep=" ") | | 207 | res[26,] <- c("", mylink2, qarr[1,2]) | | 208 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_2.htm","(Weighted Average at X(n+1)p)",""),sep=" ") | | 209 | res[27,] <- c("", mylink2, qarr[2,2]) | | 210 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_3.htm","(Empirical Distribution Function)",""),sep=" ") | | 211 | res[28,] <- c("", mylink2, qarr[3,2]) | | 212 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_4.htm","(Empirical Distribution Function - Averaging)",""),sep=" ") | | 213 | res[29,] <- c("", mylink2, qarr[4,2]) | | 214 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_5.htm","(Empirical Distribution Function - Interpolation)",""),sep=" ") | | 215 | res[30,] <- c("", mylink2, qarr[5,2]) | | 216 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_6.htm","(Closest Observation)",""),sep=" ") | | 217 | res[31,] <- c("", mylink2, qarr[6,2]) | | 218 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_7.htm","(True Basic - Statistics Graphics Toolkit)",""),sep=" ") | | 219 | res[32,] <- c("", mylink2, qarr[7,2]) | | 220 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_8.htm","(MS Excel (old versions))",""),sep=" ") | | 221 | res[33,] <- c("", mylink2, qarr[8,2]) | | 222 | mylink1 <- hyperlink("http://www.xycoon.com/variation1.htm","Coefficient of Quartile Variation","") | | 223 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_1.htm","(Weighted Average at Xnp)",""),sep=" ") | | 224 | res[34,] <- c("", mylink2, qarr[1,3]) | | 225 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_2.htm","(Weighted Average at X(n+1)p)",""),sep=" ") | | 226 | res[35,] <- c("", mylink2, qarr[2,3]) | | 227 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_3.htm","(Empirical Distribution Function)",""),sep=" ") | | 228 | res[36,] <- c("", mylink2, qarr[3,3]) | | 229 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_4.htm","(Empirical Distribution Function - Averaging)",""),sep=" ") | | 230 | res[37,] <- c("", mylink2, qarr[4,3]) | | 231 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_5.htm","(Empirical Distribution Function - Interpolation)",""),sep=" ") | | 232 | res[38,] <- c("", mylink2, qarr[5,3]) | | 233 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_6.htm","(Closest Observation)",""),sep=" ") | | 234 | res[39,] <- c("", mylink2, qarr[6,3]) | | 235 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_7.htm","(True Basic - Statistics Graphics Toolkit)",""),sep=" ") | | 236 | res[40,] <- c("", mylink2, qarr[7,3]) | | 237 | mylink2 <- paste(mylink1,hyperlink("http://www.xycoon.com/method_8.htm","(MS Excel (old versions))",""),sep=" ") | | 238 | res[41,] <- c("", mylink2, qarr[8,3]) | | 239 | res[42,] <- c("Number of all Pairs of Observations", "http://www.xycoon.com/pair_numbers.htm", lx*(lx-1)/2) | | 240 | res[43,] <- c("Squared Differences between all Pairs of Observations", "http://www.xycoon.com/squared_differences.htm", sdpo) | | 241 | res[44,] <- c("Mean Absolute Differences between all Pairs of Observations", "http://www.xycoon.com/mean_abs_differences.htm", adpo) | | 242 | res[45,] <- c("Gini Mean Difference", "http://www.xycoon.com/gini_mean_difference.htm", gmd) | | 243 | res[46,] <- c("Leik Measure of Dispersion", "http://www.xycoon.com/leiks_d.htm", bigd) | | 244 | res[47,] <- c("Index of Diversity", "http://www.xycoon.com/diversity.htm", iod) | | 245 | res[48,] <- c("Index of Qualitative Variation", "http://www.xycoon.com/qualitative_variation.htm", iod*lx/(lx-1)) | | 246 | res[49,] <- c("Coefficient of Dispersion", "http://www.xycoon.com/dispersion.htm", sum(axmm)/lx/medx) | | 247 | res[50,] <- c("Observations", "", lx) | | 248 | res | | 249 | a<-table.start() | | 250 | a<-table.row.start(a) | | 251 | a<-table.element(a,"Variability - Ungrouped Data",2,TRUE) | | 252 | a<-table.row.end(a) | | 253 | for (i in 1:num) { | | 254 | a<-table.row.start(a) | | 255 | if (res[i,1] != "") { | | 256 | a<-table.element(a,hyperlink(res[i,2],res[i,1],""),header=TRUE) | | 257 | } else { | | 258 | a<-table.element(a,res[i,2],header=TRUE) | | 259 | } | | 260 | a<-table.element(a,res[i,3]) | | 261 | a<-table.row.end(a) | | 262 | } | | 263 | a<-table.end(a) | | 264 | table.save(a,file="mytable.tab") |
|
| Cite this software as: | | Wessa P., (2008), Variability (v1.0.4) in Free Statistics Software (v1.1.23-r6), Office for Research Development and Education, URL http://www.wessa.net/rwasp_variability.wasp/ | | | The R code is based on : | | | Borghers, E, and P. Wessa, Statistics - Econometrics - Forecasting, Office for Research Development and Education, http://www.xycoon.com/ | | | | | | | | | | | | | |
|
To cite Wessa.net in publications use: Wessa, P. (2010), Free Statistics Software, Office for Research Development and Education, version 1.1.23-r6, URL http://www.wessa.net/
© Resa
R&D, and the 'Office for Research, Development, and Education' - All rights reserved. Academic license for non-commercial use only.
This website is an intellectual
and physical property of Resa R&D. This includes: html content,
graphical illustrations (gif files), computer software, online or electronic
documentation, associated media, and printed materials. The free use of the scientific content, services, and applications in this website is
granted for non commercial use only. In any case,
the source (url) should always be clearly displayed. Under no circumstances are
you allowed to reproduce, copy or redistribute the design, layout, or any
content of this website (for commercial use) including any materials contained
herein without the express written permission of Resa R&D or the Office for Research, Development, and Education.
Information provided
on this web site is provided "AS IS" without warranty of any kind, either
express or implied, including, without limitation, warranties of
merchantability, fitness for a particular purpose, and noninfringement. We use reasonable efforts to include accurate and timely information
and periodically update the information, and software without notice. However, Resa
R&D makes no warranties or representations
as to the accuracy or completeness of such information (or software), and it assumes no
liability or responsibility for errors or omissions in the content of this web
site, or any software bugs in online applications. Your use of this web site is AT YOUR OWN RISK. Under no circumstances and
under no legal theory shall Resa R&D be liable to you or any other
person for any direct, indirect, special, incidental, exemplary, or
consequential damages arising from your access to, or use of, this web site.
Software Version : 1.1.23-r6 Algorithms & Software : Patrick Wessa, PhD Facilities : Resa R&D - Office for Research, Development, and Education Server : www.wessa.net
Comments, Feedback & Errors | Privacy Policy | Statistics Resources | Wessa.net Home
|
|
|