 # Read data

> data <- read.table("~/Documents/subversion/concurrency/ITICSE 2015/stats_R/anova/join/data.csv", sep=",", header=T)

 # Calculate means

> means<- round(tapply(data$nmark, data$row, mean), digits=2)
> means
  r1   r2   r3   r4   r5 
1.15 1.00 0.92 1.02 0.99

 # Two ways of plotting raw data

> plotmeans(data$nmark~data$row, digits=2, ccol="red", mean.labels=T, main="Plot of normalized mark by row")

> boxplot(data$nmark ~ data$row, main="Normalized mark by row (mean is black dot)", xlab="row", ylab="normalized mark", col=rainbow(7))
> points(means, col="black", pch=18)

 # ANOVA

> aov_cont<- aov(data$nmark ~ data$row)
> summary(aov_cont)
              Df Sum Sq Mean Sq F value   Pr(>F)    
data$row       4   8.03  2.0084   12.64 4.24e-10 ***
Residuals   1359 216.00  0.1589                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1



If the overall P value is small, then it is unlikely that the differences you observed are due to random sampling. You can reject the idea that all the populations have identical means. This doesn't mean that every mean differs from every other mean, only that at least one differs from the rest. Look at the results of post tests to identify where the differences are.

  # TukeyHSD: To see the differences between each row
  # r5-r3 are practically the same (p = 0.9937223)
  # r3-r1 there is a significance difference (p = 0.0000000)

> tuk<- TukeyHSD(aov_cont)
> tuk
  Tukey multiple comparisons of means
    95% family-wise confidence level

Fit: aov(formula = data$nmark ~ data$row)

$`data$row`
             diff          lwr          upr     p adj
r2-r1 -0.14883090 -0.238799863 -0.058861944 0.0000663
r3-r1 -0.22727193 -0.314981409 -0.139562445 0.0000000
r4-r1 -0.13202324 -0.231855329 -0.032191152 0.0029028
r5-r1 -0.16338633 -0.331604586  0.004831930 0.0617380
r3-r2 -0.07844102 -0.153908191 -0.002973855 0.0370012
r4-r2  0.01680766 -0.072460395  0.106075721 0.9859588
r5-r2 -0.01455542 -0.176727316  0.147616467 0.9992031
r4-r3  0.09524869  0.008258309  0.182239064 0.0236642
r5-r3  0.06388560 -0.097043771  0.224814969 0.8146924
r5-r4 -0.03136309 -0.199207524  0.136481349 0.9863541

# In following plot: Significant differences are the ones which not cross the zero value.

> plot (tuk)

Para hacer mantel test creamos un nuevo conjunto de datos donde las row dejan de ser r1, r2,etc para ser 1,2,etc.

> data <- read.table("~/Documents/subversion/concurrency/ITICSE 2015/stats_R/anova/join/data_mantel.csv", sep=",", header=T)

> diffrow.dist <- dist(data$row)
> diffmark.dist <- dist(data$nmark)

> mantel.rtest(diffmark.dist, diffrow.dist, nrepet = 999)
Monte-Carlo test
Observation: 0.002299506 
Call: mantel.rtest(m1 = diffmark.dist, m2 = diffrow.dist, nrepet = 999)
Based on 999 replicates
Simulated p-value: 0.434 