Brothers’ Heads

WarriWes

March 27, 2018


The data consist of measurements of the length and breadth of the heads of pairs of adult brothers in 25 randomly sampled families. All measurements are expressed in millimetres.
The data were obtained from Frets, G.P. (1921) Heredity of head form in man. Genetica, 3, 193.

https://vincentarelbundock.github.io/Rdatasets/doc/boot/frets.html


Read file into a data.frame, check the first 5 rows and structure

data <- read.csv('frets.csv')
head(data)
##   X  l1  b1  l2  b2
## 1 1 191 155 179 145
## 2 2 195 149 201 152
## 3 3 181 148 185 149
## 4 4 183 153 188 149
## 5 5 176 144 171 142
## 6 6 208 157 192 152
str(data)
## 'data.frame':    25 obs. of  5 variables:
##  $ X : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ l1: int  191 195 181 183 176 208 189 197 188 192 ...
##  $ b1: int  155 149 148 153 144 157 150 159 152 150 ...
##  $ l2: int  179 201 185 188 171 192 190 189 197 187 ...
##  $ b2: int  145 152 149 149 142 152 149 152 159 151 ...

Remove ‘x’ column and check the last few rows

data <- data[,-1]
tail(data)
##     l1  b1  l2  b2
## 20 175 140 165 137
## 21 192 154 185 152
## 22 174 143 178 147
## 23 176 139 176 143
## 24 197 167 200 158
## 25 190 163 187 150

Calculate correlations between L1 and L2 (brother 1 head length, brother 2 head length), and between B1 and B2 (brother 1 head breadth, brother 2 head breadth)

data_cor <- cor(data)
l_cor <- data_cor['l1', 'l2']
b_cor <- data_cor['b1', 'b2']

Plot the relationships between head dimensions between brothers, including linear regressions

library(ggplot2)
create_anno <- function(x) {
        paste0('R: ', round(x, 4), ',\nR²: ', round(x ** 2, 4)) 
}

l_plot <- ggplot(data, aes(x = l1, y = l2)) +
        geom_point(col = 'blue') +
        geom_smooth(method = 'lm') +
        annotate(geom = 'text', label = create_anno(l_cor), x = 195, y = 165) +
        ggtitle('Head Lengths (mm)') +
        xlab('Length 1') +
        ylab('Length 2')

b_plot <- ggplot(data, aes(x = b1, y = b2)) +
        geom_point(col = 'red') +
        geom_smooth(method = 'lm', col = 'red') +
        annotate(geom = 'text', label = create_anno(b_cor), x = 155, y = 135) +
        ggtitle('Head Breadths (mm)') +
        xlab('Breadth 1') +
        ylab('Breadth 2')

Display the regressions for length and breadth side-by-side, including the correlations and R² values on each figure

library(grid)
library(gridExtra)
grid.arrange(l_plot, b_plot, ncol=2, top = "Relationship Between Brothers' Head Sizes")