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.

In [2]:

```
data <- read.csv("input.csv", sep = ";")
head(data)
```

In [3]:

```
data$mean <- (data$'p1'+data$'p2')/2
head(data)
```

In [4]:

```
data$distance <- data$'p1'-data$'p2'
```

In [5]:

```
data
```

In [6]:

```
M <- mean(c(data$'p1',data$'p2'), na.rm = TRUE)
M
```

In [7]:

```
data$"(mean-M)²" <- (data$mean - M)^2
```

In [8]:

```
data
```

In [9]:

```
data$"distance²" <- (data$distance)^2
```

In [10]:

```
data
```

In [11]:

```
SumMeanSquare2 <- sum(data$"(mean-M)²", na.rm = TRUE)
```

In [12]:

```
SumMeanSquare2
```

In [13]:

```
SumDistance2 <- sum(data$"distance²", na.rm = TRUE)
```

In [14]:

```
SumDistance2
```

In [15]:

```
MSb <- (2*SumMeanSquare2) / (length(data$Dyade)-1)
```

In [16]:

```
MSb
```

In [17]:

```
length(data$mean[!is.na(data$mean)])
```

In [18]:

```
MSw <- SumDistance2 / (2*length(data$mean))
```

In [19]:

```
MSw
```

In [20]:

```
ICC <- (MSb - MSw) / (MSb + MSw)
```

In [21]:

```
ICC
```

In [22]:

```
F <- MSb / MSw
```

In [23]:

```
F
```

In [24]:

```
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.