これはR Tutorial Part2 Chapter08 (Numerical Measures) のノートです。 slideはこちら 。
> library(MASS) > mean(faithful$eruption) [1] 3.487783 > median(faithful$eruption) [1] 4
> quantile(faithful$eruption) 0% 25% 50% 75% 100% 1.60000 2.16275 4.00000 4.45425 5.10000 > x = sort(faithful$eruption) > x[1+floor((length(x) - 1)/4)] + (x[1+ceiling((length(x) - 1)/4)] - x[1+floor((length(x) - 1)/4)]) * 3 / 4 [1] 2.16275 > quantile(faithful$eruption, c(.32, .57, .98)) 32% 57% 98% 2.39524 4.13300 4.93300
> max(faithful$eruption) [1] 5.1 > min(faithful$eruption) [1] 1.6 > max(faithful$eruption) - min(faithful$eruption) [1] 3.5
> IQR(faithful$eruption) [1] 2.2915 > x = quantile(faithful$eruption) > x[4] - x[2] 75% 2.2915
> boxplot(faithful$eruption, horizontal=TRUE)
※ 箱のなかの線はmedian
> var(faithful$eruption) [1] 1.302728 > sd(faithful$eruption) [1] 1.141371 > var2 <- function(x) { sum((x - mean(x)) ^ 2) / length(x) } # 普通の分散 > var2(faithful$eruption) [1] 1.297939
> cov(faithful$eruption, faithful$waiting) [1] 13.97781 > cor(faithful$eruption, faithful$waiting) [1] 0.9008112
correlation coefficientが1に近いほど正の相関があるといえる
Functions for latent class analysis, short time Fourier transform, fuzzy clustering, support vector machines, shortest path computation, bagged clustering, naive Bayes classifier
> install.packages('e1071')
http://cran.r-project.org/web/packages/e1071/index.html
> library(e1071) > moment(faithful$eruption, order=3, center=TRUE) [1] -0.6149059
> skewness(faithful$eruption) [1] -0.4135498 > kurtosis(faithful$eruption) [1] -1.511605