# Compute intraclass correlation to check non-independance of dyadic data¶

## Purpose¶

I paraphrased Field et al. (2012, chapter 19) below to explain the underlying idea:

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.

## Requirements¶

This script require R. You need the free software R : go to R download page

# Code¶

In :
data <- read.csv("input.csv", sep = ";")

186
253
372
485
587
656

In :
data$mean <- (data$'p1'+data$'p2')/2 head(data)  Dyadep1p2mean 1 8 6 7.0 2 5 3 4.0 3 7 2 4.5 4 8 5 6.5 5 8 7 7.5 6 5 6 5.5 ### Create new column with distances between the two participants¶ In : data$distance <- data$'p1'-data$'p2'

In :
data

1 8 6 7.0 2
2 5 3 4.0 2
3 7 2 4.5 5
4 8 5 6.5 3
5 8 7 7.5 1
6 5 6 5.5-1

### Compute mean of all 2n scores¶

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

5.83333333333333

### Compute (mean - M)² for each dyad¶

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

In :
data

1 8 6 7.0 2 1.3611111
2 5 3 4.0 2 3.3611111
3 7 2 4.5 5 1.7777778
4 8 5 6.5 3 0.4444444
5 8 7 7.5 1 2.7777778
6 5 6 5.5 -1 0.1111111

### Compute distance² for each dyad¶

In :
data$"distance²" <- (data$distance)^2

In :
data

1 8 6 7.0 2 1.3611111 4
2 5 3 4.0 2 3.3611111 4
3 7 2 4.5 5 1.777777825
4 8 5 6.5 3 0.4444444 9
5 8 7 7.5 1 2.7777778 1
6 5 6 5.5 -1 0.1111111 1

In :
SumMeanSquare2 <- sum(data$"(mean-M)²", na.rm = TRUE)  In : SumMeanSquare2  9.83333333333333 ### Compute sum of distance²¶ In : SumDistance2 <- sum(data$"distance²", na.rm = TRUE)

In :
SumDistance2

44

In :
MSb <- (2*SumMeanSquare2) / (length(data$Dyade)-1)  In : MSb  3.93333333333333 ### Compute mean square within dyads (MSw)¶ In : length(data$mean[!is.na(data$mean)])  6 In : MSw <- SumDistance2 / (2*length(data$mean))

In :
MSw

3.66666666666667

### Compute intraclass correlation (ICC)¶

In :
ICC <- (MSb - MSw) / (MSb + MSw)

In :
ICC

0.0350877192982455

### Compute F value¶

In :
F <- MSb / MSw

In :
F

1.07272727272727

### Compute p value¶

In :
p <- pf(q=F, df1=length(data$Dyad)-1, df2=length(data$Dyad), lower.tail=TRUE)
p

0.541775047119164

## Références¶

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.