Maatstaven.
> bron <- "http://www.mzandee.net/~zandee/statistiek/data/gegevens.txt"
> cohort <- read.table(bron, header=T)
> attach(cohort)
> names(cohort)
[1] "lichaam" "arm" "pols" "geslacht" "hand" "ogen"
Rekenkundig gemiddelde
> mean(lichaam)
[1] 177.4470
Mediaan
> median(lichaam)
[1] 179
Modus
# create a table with the values sorted by frequency
sortvar <- sort(table(lichaam))
# get the max frequency
maxfreq <- max(sortvar)
# find values with high frequency
modeTable <- which(sortvar == maxfreq)
# get the name (value) of the most frequent value
themoderesult <- names(modeTable)
# Report
themoderesult
[1] "180"
# in 1 regel:
> which(tabulate(lichaam,nbins=max(lichaam)+1)
+ ==max(tabulate(lichaam,nbins=max(lichaam)+1)))
Meetkundig gemiddelde
> mg <- function(x){exp(sum(log(x))/length(x))}
> mg(lichaam)
[1] 177.1838
Harmonisch gemiddelde
> hg <- function(x){length(x)/sum(1/x)}
> hg(lichaam)
[1] 176.9154
Kwantielen
> quantile(lichaam, prob=c(.1, .25, .5, .75, .9))
10% 25% 50% 75% 90%
164.50 171.25 179.00 184.75 191.00
Variantie
> var(lichaam)
[1] 92.9933
Standaarddeviatie
> sqrt(var(lichaam))
[1] 9.643303
Scheefheid
SP = Pearson-coƫfficient voor scheefheid = 3*(gemiddelde - mediaan)/s =
> SP <- 3 * (mean(lichaam) - median(lichaam))/sqrt(var(lichaam))