I paraphrased Field et al. (2012, chapter 19) below to explain the underlying idea:
In a dyadic context, the ICC represents the proportion of the total variability in the outcome that is attributable to the dyad. It follows that if a dyad has had a big effect on the dyad members within it then the variability within the dyad will be small (the dyad members will behave similarly). As such, variability in the outcome within dyads is minimized, and variability in the outcome between dyads is maximized; Therefore, the ICC is large. Conversely, if the dyad has little effect on the dyad members then the outcome will vary a lot within dyads, which will make differences between dyads relatively small. Therefore, the ICC is small too. Thus, the ICC tells us that variability within levels of a contextual variable (in this case the dyad to which a dyad member belongs) is small, but between levels of a contextual variable (comparing dyads) is large. As such, the ICC is a good gauge of whether a contextual variable has an effect on the outcome.
The following intraclass correlation concerns the measurement of non-independence for indistinguishable members based on ANOVA techniques with interval level of measurement. Please refer to Kenny, Kashy and Cook (2006, pp.34-35) for more details.
This script require R. You need the free software R : go to R download page
Your data file need to be in a dyadic structure : go to this page to see how restructure your table in python.
data <- read.csv("input.csv", sep = ";")
head(data)
data$mean <- (data$'p1'+data$'p2')/2
head(data)
data$distance <- data$'p1'-data$'p2'
data
M <- mean(c(data$'p1',data$'p2'), na.rm = TRUE)
M
data$"(mean-M)²" <- (data$mean - M)^2
data
data$"distance²" <- (data$distance)^2
data
SumMeanSquare2 <- sum(data$"(mean-M)²", na.rm = TRUE)
SumMeanSquare2
SumDistance2 <- sum(data$"distance²", na.rm = TRUE)
SumDistance2
MSb <- (2*SumMeanSquare2) / (length(data$Dyade)-1)
MSb
length(data$mean[!is.na(data$mean)])
MSw <- SumDistance2 / (2*length(data$mean))
MSw
ICC <- (MSb - MSw) / (MSb + MSw)
ICC
F <- MSb / MSw
F
p <- pf(q=F, df1=length(data$Dyad)-1, df2=length(data$Dyad), lower.tail=TRUE)
p
Field, Andy, Jeremy Miles, and Zoë Field. "Discovering statistics using R." (2012).
Kenny, David A., Deborah A. Kashy, and William L. Cook. Dyadic data analysis. Guilford press, 2006.