This page dispays preliminary descriptive statistics for social isolation variables in E-Risk. The contents are listed on the left hand side of the page. Social isolation was measured using items from the Children’s Behaviour Checklist (CBCL), responses were scored 0 (not true), 1 (somewhat true) and 2 (often true) were summed to make a total score and then were averaged from both parents and teachers:

  • “complains of loneliness”
  • “doesn’t get along with other children [pupils]”
  • “feels or complains that no-one loves him/her”
  • “would rather be alone than with others”
  • “not liked by other children [pupils]”
  • “withdrawn, doesn’t get involved with others”

Missingness descriptives

Visits were conducted when the children were aged 5 (100% participation), 7 (98%), 10 (96%), 12 (96%), and 18 years (93%). Rates of missingness for social isolation items is reported below. First, the number of time points missing per person is reported, then social isolation item frequencies are displayed for each age.

Frequency tables social isolation

Time points missing per person

dat %>%
  rename(`Social isolation NAs per person` = na.per.person.si) %>%
  freq(`Social isolation NAs per person`, 
       cumul = FALSE, 
       display.type = FALSE, 
       headings = FALSE,
       style = "rmarkdown",
       report.nas = FALSE)
  Freq %
0 2079 93.15
1 89 3.99
2 46 2.06
3 18 0.81
Total 2232 100.00

Frequencies at age 5

dat %>%
  rename(`Social isolation age 5` = isolation_combined_05) %>%
  freq(`Social isolation age 5`, 
       cumul = FALSE, 
       display.type = FALSE, 
       headings = FALSE, 
       style = "rmarkdown")
  Freq % Valid % Total
0 894 40.05 40.05
0.5 512 22.94 22.94
0.6 4 0.18 0.18
0.75 1 0.04 0.04
1 308 13.80 13.80
1.2 3 0.13 0.13
1.25 1 0.04 0.04
1.5 191 8.56 8.56
1.6 1 0.04 0.04
1.7 1 0.04 0.04
1.8 1 0.04 0.04
2 119 5.33 5.33
2.3 1 0.04 0.04
2.5 54 2.42 2.42
2.8 1 0.04 0.04
2.9 1 0.04 0.04
3 48 2.15 2.15
3.3 1 0.04 0.04
3.4 1 0.04 0.04
3.5 23 1.03 1.03
3.6 1 0.04 0.04
3.9 1 0.04 0.04
4 22 0.99 0.99
4.4 1 0.04 0.04
4.5 7 0.31 0.31
5 14 0.63 0.63
5.5 4 0.18 0.18
6 5 0.22 0.22
6.5 5 0.22 0.22
7 2 0.09 0.09
8 1 0.04 0.04
9 1 0.04 0.04
10 1 0.04 0.04
12 1 0.04 0.04
<NA> 0 0.00
Total 2232 100.00 100.00

Zero NAs at age 5.

Frequencies at age 7

dat %>%
  rename(`Social isolation age 7` = isolation_combined_07) %>%
  freq(`Social isolation age 7`, 
       cumul = FALSE, 
       display.type = FALSE, 
       headings = FALSE, 
       style = "rmarkdown")
  Freq % Valid % Total
0 912 41.87 40.86
0.5 451 20.71 20.21
0.6 3 0.14 0.13
1 308 14.14 13.80
1.1 2 0.09 0.09
1.2 1 0.05 0.04
1.5 169 7.76 7.57
2 111 5.10 4.97
2.2 2 0.09 0.09
2.5 73 3.35 3.27
2.6 1 0.05 0.04
3 49 2.25 2.20
3.5 25 1.15 1.12
3.7 1 0.05 0.04
4 21 0.96 0.94
4.4 1 0.05 0.04
4.5 11 0.51 0.49
5 15 0.69 0.67
5.5 3 0.14 0.13
6 6 0.28 0.27
6.5 1 0.05 0.04
6.6 1 0.05 0.04
7 4 0.18 0.18
7.5 2 0.09 0.09
8 3 0.14 0.13
9.5 2 0.09 0.09
<NA> 54 2.42
Total 2232 100.00 100.00

54 NAs at age 7.

Frequencies at age 10

dat %>%
  rename(`Social isolation age 10` = isolation_combined_10) %>%
  freq(`Social isolation age 10`, 
       cumul = FALSE, 
       display.type = FALSE, 
       headings = FALSE, 
       style = "rmarkdown")
  Freq % Valid % Total
0 843 39.43 37.77
0.5 440 20.58 19.71
0.6 5 0.23 0.22
1 300 14.03 13.44
1.1 1 0.05 0.04
1.2 2 0.09 0.09
1.5 139 6.50 6.23
2 139 6.50 6.23
2.5 65 3.04 2.91
2.6 1 0.05 0.04
2.7 1 0.05 0.04
3 68 3.18 3.05
3.2 2 0.09 0.09
3.5 44 2.06 1.97
3.6 1 0.05 0.04
4 22 1.03 0.99
4.5 19 0.89 0.85
5 15 0.70 0.67
5.5 5 0.23 0.22
6 10 0.47 0.45
6.4 1 0.05 0.04
6.6 1 0.05 0.04
7 5 0.23 0.22
7.3 1 0.05 0.04
7.5 3 0.14 0.13
7.9 1 0.05 0.04
8 1 0.05 0.04
9 1 0.05 0.04
10 1 0.05 0.04
11 1 0.05 0.04
<NA> 94 4.21
Total 2232 100.00 100.00

94 NAs at age 10.

Frequencies at age 12

freq(dat$isolation_combined_12, 
       cumul = FALSE, 
       display.type = FALSE, 
       headings = FALSE, 
       style = "rmarkdown")
  Freq % Valid % Total
0 922 42.98 41.31
0.5 358 16.69 16.04
0.6 6 0.28 0.27
0.75 3 0.14 0.13
1 294 13.71 13.17
1.1 2 0.09 0.09
1.2 4 0.19 0.18
1.25 1 0.05 0.04
1.5 139 6.48 6.23
1.7 2 0.09 0.09
1.75 2 0.09 0.09
1.8 5 0.23 0.22
2 147 6.85 6.59
2.5 56 2.61 2.51
2.7 1 0.05 0.04
2.75 1 0.05 0.04
2.9 1 0.05 0.04
3 63 2.94 2.82
3.5 31 1.45 1.39
3.75 1 0.05 0.04
4 33 1.54 1.48
4.5 13 0.61 0.58
4.9 1 0.05 0.04
5 13 0.61 0.58
5.2 1 0.05 0.04
5.4 1 0.05 0.04
5.5 11 0.51 0.49
5.6 1 0.05 0.04
6 16 0.75 0.72
6.5 5 0.23 0.22
7.5 2 0.09 0.09
8 1 0.05 0.04
9 3 0.14 0.13
10 4 0.19 0.18
11 1 0.05 0.04
<NA> 87 3.90
Total 2232 100.00 100.00

87 NAs at age 12.

Groups for participants missing 2 or 3 time points

To check that data is missing at random (MAR), we created two variables that indicate group membershop based on missingness. The first variable split those that were missing three time points (N=18) into one group, and everyone else in another group. The second variable split those that were missing two time points (N=46) into one group (exluding those missing three time points), and those missing 1 or zero into the other group. We then tested for differences in social isolation, SES, IQ, internalising behaviours, and extermalising behaviours at age 5, dependednt on the two mimssingness group variables created.

# group with 18 missing 3 time points vs everyone else
dat <- dat %>%
  mutate(
    missing_3_time_points = 
      if_else(
        na.per.person.si > 2, 
        1,
        0) %>%
      recode_factor(
        "0" = "No",
        "1" = "Yes"
      )
  )

# create group of just 18 who have 3 missing time points
dat.18 <- filter(dat, missing_3_time_points == "Yes")

# excluding the 18 missing 3 time points, those with 2 missing time points vs every one else
dat.missing.3time <- filter(dat,
                      na.per.person.si != 3)

dat.missing.3time <- dat.missing.3time %>%
  mutate(
    missing_2_time_points = 
      if_else(
        na.per.person.si > 1 & na.per.person.si < 3, 
        1,
        0) %>%
      recode_factor(
        "0" = "No",
        "1" = "Yes"
      )
  )

Differences for those who have missing social isolation data

Results from t-tests and Chi square tests assessing significant group differences for those who were missing three time points, and for those who were missing two time pionts. 46 people were missing two of the four time points. 18 people were missing three out of four time points. Results are reported under each tab separately.

# This function creates a results sentence for all t-tests and cho square tests to follow. 
test.sentence <- function(test="t"|"X-squared", test.data, time.point.missing = "two"|"three", variable){
  part1 <- cat(paste0(variable, " at age five was not significantly different for those missing ", time.point.missing, " time points, compared to everyone else (", test, " =", round(test.data$statistic, 3), ", df=", round(test.data$parameter, 3), ", p=", round(test.data$p.value, 3), "). "))
  if (test== "X-squared"){print(part1)}
  if (test=="t"){
  part1
  cat(paste0(part1, " Mean for group **not** missing ", time.point.missing, " time points = ", round(test.data$estimate[1], 3), ", mean for group missing ",time.point.missing, " three time points = ", round(test.data$estimate[2], 3), ". "))
  }
}

Social isolation at age 5

ttest_SI_3time <- t.test( 
  isolation_combined_05 ~ missing_3_time_points,
  data = dat,
  alternative = "two.sided",
  conf.level = 0.95)
test.sentence(test = "t", test.data = ttest_SI_3time, time.point.missing = "three", variable = "Social isolation")

Social isolation at age five was not significantly different for those missing three time points, compared to everyone else (t =0.713, df=17.245, p=0.485). Mean for group not missing three time points = 0.815, mean for group missing three three time points = 0.611.

ttest_SI_2time <- t.test( 
  isolation_combined_05 ~ missing_2_time_points,
  data = dat.missing.3time,
  alternative = "two.sided",
  conf.level = 0.95)
test.sentence(test = "t", test.data = ttest_SI_2time, time.point.missing = "two", variable = "Social isolation")

Social isolation at age five was not significantly different for those missing two time points, compared to everyone else (t =-0.799, df=46.422, p=0.429). Mean for group not missing two time points = 0.811, mean for group missing two three time points = 0.967.

SES at age 5

chisq_SES_3time <- chisq.test(dat$SES,dat$missing_3_time_points) # nonsig
test.sentence(test = "X-squared", test.data = chisq_SES_3time, time.point.missing = "three", variable = "Socioeconomic status")

Socioeconomic status at age five was not significantly different for those missing three time points, compared to everyone else (X-squared =1.394, df=2, p=0.498). NULL

chisq_SES_2time <- chisq.test(dat.missing.3time$SES, dat.missing.3time$missing_2_time_points) # nonsig
test.sentence(test = "X-squared", test.data = chisq_SES_2time, time.point.missing = "two", variable = "Socioeconomic status")

Socioeconomic status at age five was not significantly different for those missing two time points, compared to everyone else (X-squared =5.219, df=2, p=0.074). NULL

IQ at age 5

ttest_IQ_3time <- t.test( #nonsig
  IQ_05 ~ missing_3_time_points,
  data = dat,
  alternative = "two.sided",
  conf.level = 0.95) 
test.sentence(test = "t", test.data = ttest_IQ_3time, time.point.missing = "three", variable = "IQ")

IQ at age five was not significantly different for those missing three time points, compared to everyone else (t =1.224, df=17.501, p=0.237). Mean for group not missing three time points = 95.82, mean for group missing three three time points = 92.667.

ttest_IQ_2time <- t.test( #SIGNIFICANT - missing two time points has lower IQ
  IQ_05 ~ missing_2_time_points,
  data = dat.missing.3time,
  alternative = "two.sided",
  conf.level = 0.95) 
paste0("IQ at age five was **significantly** different for those missing two time points, compared to everyone else (t=", round(ttest_IQ_2time$statistic, 3), ", df=", round(ttest_IQ_2time$parameter, 3), ", p=", round(ttest_IQ_2time$p.value, 3), "). Mean for group **not** missing two time points = ", round(ttest_IQ_2time$estimate[1], 3), ", mean for group missing two time points = ", round(ttest_IQ_2time$estimate[2], 3))

[1] “IQ at age five was significantly different for those missing two time points, compared to everyone else (t=2.532, df=45.853, p=0.015). Mean for group not missing two time points = 95.934, mean for group missing two time points = 90.4”

Internalising problems at age 5

ttest_int_3time <- t.test( #nonsig
  internalising_combined_excl_sis_05 ~ missing_3_time_points,
  data = dat,
  alternative = "two.sided",
  conf.level = 0.95) 
test.sentence(test = "t", test.data = ttest_int_3time, time.point.missing = "three", variable = "Internalising behaviours")

Internalising behaviours at age five was not significantly different for those missing three time points, compared to everyone else (t =-0.563, df=17.256, p=0.581). Mean for group not missing three time points = 6.87, mean for group missing three three time points = 7.505.

ttest_int_2time <- t.test( #nonsig
  internalising_combined_excl_sis_05 ~ missing_2_time_points,
  data = dat.missing.3time,
  alternative = "two.sided",
  conf.level = 0.95) 
test.sentence(test = "t", test.data = ttest_int_2time, time.point.missing = "two", variable = "Internalising behaviours")

Internalising behaviours at age five was not significantly different for those missing two time points, compared to everyone else (t =0.085, df=46.227, p=0.933). Mean for group not missing two time points = 6.871, mean for group missing two three time points = 6.799.

Externalising problems at age 5

ttest_ext_3time <- t.test( #nonsig
  externalising_combined_05 ~ missing_3_time_points,
  data = dat,
  alternative = "two.sided",
  conf.level = 0.95) 
test.sentence(test = "t", test.data = ttest_ext_3time, time.point.missing = "three", variable = "Externalising behaviours")

Externalising behaviours at age five was not significantly different for those missing three time points, compared to everyone else (t =0.361, df=17.289, p=0.723). Mean for group not missing three time points = 18.313, mean for group missing three three time points = 17.167.

ttest_ext_2time <- t.test( #nonsig
  externalising_combined_05 ~ missing_2_time_points,
  data = dat.missing.3time,
  alternative = "two.sided",
  conf.level = 0.95) 
test.sentence(test = "t", test.data = ttest_ext_2time, time.point.missing = "two", variable = "Externalising behaviours")

Externalising behaviours at age five was not significantly different for those missing two time points, compared to everyone else (t =-1.195, df=46.891, p=0.238). Mean for group not missing two time points = 18.262, mean for group missing two three time points = 20.724.

Missingness differences at age 18

We found no differences between those who did and did not take part at age 18 in terms of socioeconomic status (SES) assessed when the cohort was initially defined (χ2 = 0.86, p = 0.65), age-5 IQ scores (t = 0.98, p = 0.33), or age-5 emotional or behavioural problems (t = 0.40, p = 0.69 and t = 0.41, p = 0.68, respectively). There were 2066 complete responses at age 18 (92.56% retention).

# check the freq 
employment.freq <- freq(dat$not_in_employment_education_18,
     cumul = FALSE)

# create data set for those who did and did not take part at age 18 
## 166 participants
dat_not_age_18 <- dat %>%
  filter(is.na(not_in_employment_education_18))
## 2066 participants
dat_age_18 <- dat %>%
  filter(!is.na(not_in_employment_education_18))

# create variable in original data set based on cut off
dat <- dat %>%
  mutate(
    took_part_at_18 = 
      if_else(
        !is.na(not_in_employment_education_18), 
        1,
        0) %>%
      recode_factor(
        "0" = "No",
        "1" = "Yes"
      )
  )

# check
# table(dat$took_part_at_18)

# Social isolation - t-test - nonsig
ttest_SI_age18 <- t.test( 
  isolation_combined_05 ~ took_part_at_18,
  data = dat,
  alternative = "two.sided",
  conf.level = 0.95) 

# IQ - t-test - nonsig
ttest_IQ_age18 <- t.test( 
  IQ_05 ~ took_part_at_18,
  data = dat,
  alternative = "two.sided",
  conf.level = 0.95) 

# externalising - t-test - nonsig
ttest_ext_age18 <- t.test( 
  externalising_combined_05 ~ took_part_at_18,
  data = dat,
  alternative = "two.sided",
  conf.level = 0.95) 

# internalising - t-test - nonsig
ttest_int_age18 <- t.test( 
  internalising_combined_excl_sis_05 ~ took_part_at_18,
  data = dat,
  alternative = "two.sided",
  conf.level = 0.95) 

# SES - chi square
chisq_SES_age18 <- chisq.test(dat$SES,
                              dat$took_part_at_18) # nonsig

Means across all time points

Below are the mean social isolation scores plotted for each time point. Underneath are the descriptives for social isolation stratified by combined report (mother and teacher), mother report, and teacher report.

#summarize the data fir the plot 
dat_summary.isolation <- summarySE(dat_long, 
                            measurevar = "social_isolation", 
                            groupvars = c("time_point"),
                            na.rm=TRUE)
#create plot
diff.plot <- ggplot(dat_summary.isolation, 
       aes(x = time_point, 
           y = social_isolation,
           group = 1)) + 
    geom_errorbar(aes(ymin = social_isolation - se, 
                      ymax = social_isolation + se), 
                  colour = "black", 
                  width = 0.1) +
    geom_line(colour = "red") +
    geom_point(size = 3, 
               shape = 21, 
               fill = "white") + # 21 is filled circle
    xlab("Time point") +
    ylab("Social isolation") +
    ggtitle("Average differences in social isolation at time point 5, 7, 10 and 12") +
    expand_limits(y = 0) +                     
    scale_y_continuous(expand = c(0.1,0.1),
                     limits = c(0,12),
                     breaks = seq(0, 12, 2)) +
  theme_bw()

#create scaled plot
diff.plot.scaled <- diff.plot+ 
  scale_y_continuous(expand = c(0.1,0.1),
                     limits = c(0,2),
                     breaks = seq(0, 2, 0.25)) +
   ggtitle("Scaled average differences in social isolation at time point 5, 7, 10 and 12")
diff.plot.scaled

Combined mother/teacher report of social isolation

dat %>%
  select(`Age five` = isolation_combined_05,
         `Age seven` = isolation_combined_07,
         `Age ten` = isolation_combined_10,
         `Age twelve` = isolation_combined_12) %>%
  descr( 
      headings = FALSE,
      stats =  c("mean", "sd", "min", "max", "skewness", "kurtosis", "n.valid", "pct.valid"), 
      style = "rmarkdown") 
  Age five Age seven Age ten Age twelve
Mean 0.81 0.83 0.94 0.94
Std.Dev 1.13 1.18 1.30 1.37
Min 0.00 0.00 0.00 0.00
Max 12.00 9.50 11.00 11.00
Skewness 2.71 2.50 2.32 2.50
Kurtosis 12.00 8.84 7.54 8.76
N.Valid 2232.00 2178.00 2138.00 2145.00
Pct.Valid 100.00 97.58 95.79 96.10

Mother report of social isolation

dat %>%
  select(`Age five` = isolation_mother_05,
         `Age seven` = isolation_mother_07,
         `Age ten` = isolation_mother_10,
         `Age twelve` = isolation_mother_12) %>%
  descr( 
      headings = FALSE,
      stats =  c("mean", "sd", "min", "max", "skewness", "kurtosis", "n.valid", "pct.valid"), 
      style = "rmarkdown") 
  Age five Age seven Age ten Age twelve
Mean 0.97 0.98 1.10 1.05
Std.Dev 1.44 1.53 1.63 1.66
Min 0.00 0.00 0.00 0.00
Max 12.00 12.00 11.00 12.00
Skewness 2.17 2.31 2.22 2.31
Kurtosis 6.33 6.76 6.36 6.95
N.Valid 2230.00 2178.00 2138.00 2141.00
Pct.Valid 99.91 97.58 95.79 95.92

Teacher report

dat %>%
  select(`Age five` = isolation_teacher_05,
         `Age seven` = isolation_teacher_07,
         `Age ten` = isolation_teacher_10,
         `Age twelve` = isolation_teacher_12) %>%
  descr( 
      headings = FALSE,
      stats =  c("mean", "sd", "min", "max", "skewness", "kurtosis", "n.valid", "pct.valid"), 
      style = "rmarkdown") 
  Age five Age seven Age ten Age twelve
Mean 0.62 0.64 0.72 0.77
Std.Dev 1.25 1.31 1.46 1.49
Min 0.00 0.00 0.00 0.00
Max 12.00 10.00 12.00 12.00
Skewness 3.08 3.05 2.85 2.56
Kurtosis 13.16 11.56 9.76 7.71
N.Valid 2093.00 2026.00 1924.00 1775.00
Pct.Valid 93.77 90.77 86.20 79.53

Social isolation split by sex

Below are violin plots showing social isolation combined report scores stratified by sex.

Age 5

dat %>%
  ggplot(
    mapping = aes(
    x = sex,
    y = isolation_combined_05,
    fill = sex)) +
  geom_hline(yintercept = 5, linetype = "dashed", color = "gray") +
  geom_hline(yintercept = 10, linetype = "dashed", color = "gray") +
  geom_hline(yintercept = 15, linetype = "dashed", color = "gray") +
  geom_flat_violin(
    position = position_nudge(x = .2, y = 0),
    trim = FALSE,
    alpha = 0.5
    ) +
  geom_point(
    aes(
      y = isolation_combined_05,
      color = sex),
    position = position_jitter(width = .15),
    size = .5,
    alpha = 0.8) +
 stat_summary(fun = mean,
              fun.min = function(x) mean(x)* sd(x),
              fun.max = function(x) mean(x) + sd(x),
              geom = "pointrange"
              ) +
  labs(
    title = "Social isolation in males and females at age 5",
    y = "Social isolation",
    fill = "Sex") +
  theme_personal +
  theme(
    axis.text.y = element_blank()
  ) +
  scale_fill_manual(
    values = palette2,
    breaks = c("Male", "Female")
) +
  scale_alpha(guide = 'none') +
  scale_size(guide = 'none') +
  scale_color_manual(
    values = palette2,
    breaks = c("Male", "Female"),
    guide = "none") +
  coord_flip()

Age 7

dat %>%
  ggplot(
    mapping = aes(
    x = sex,
    y = isolation_combined_07,
    fill = sex)) +
  geom_hline(yintercept = 5, linetype = "dashed", color = "gray") +
  geom_hline(yintercept = 10, linetype = "dashed", color = "gray") +
  geom_hline(yintercept = 15, linetype = "dashed", color = "gray") +
  geom_flat_violin(
    position = position_nudge(x = .2, y = 0),
    trim = FALSE,
    alpha = 0.5
    ) +
  geom_point(
    aes(
      y = isolation_combined_05,
      color = sex),
    position = position_jitter(width = .15),
    size = .5,
    alpha = 0.8) +
 stat_summary(fun = mean,
              fun.min = function(x) mean(x)* sd(x),
              fun.max = function(x) mean(x) + sd(x),
              geom = "pointrange"
              ) +
  labs(
    title = "Social isolation in males and females at age 7",
    y = "Social isolation",
    fill = "Sex") +
  theme_personal +
  theme(
    axis.text.y = element_blank()
  ) +
  scale_fill_manual(
    values = palette2,
    breaks = c("Male", "Female")
) +
  scale_alpha(guide = 'none') +
  scale_size(guide = 'none') +
  scale_color_manual(
    values = palette2,
    breaks = c("Male", "Female"),
    guide = "none") +
  coord_flip()

Age 10

dat %>%
  ggplot(
    mapping = aes(
    x = sex,
    y = isolation_combined_10,
    fill = sex)) +
  geom_hline(yintercept = 5, linetype = "dashed", color = "gray") +
  geom_hline(yintercept = 10, linetype = "dashed", color = "gray") +
  geom_hline(yintercept = 15, linetype = "dashed", color = "gray") +
  geom_flat_violin(
    position = position_nudge(x = .2, y = 0),
    trim = FALSE,
    alpha = 0.5
    ) +
  geom_point(
    aes(
      y = isolation_combined_05,
      color = sex),
    position = position_jitter(width = .15),
    size = .5,
    alpha = 0.8) +
 stat_summary(fun = mean,
              fun.min = function(x) mean(x)* sd(x),
              fun.max = function(x) mean(x) + sd(x),
              geom = "pointrange"
              ) +
  labs(
    title = "Social isolation in males and females at age 10",
    y = "Social isolation",
    fill = "Sex") +
  theme_personal +
  theme(
    axis.text.y = element_blank()
  ) +
  scale_fill_manual(
    values = palette2,
    breaks = c("Male", "Female")
) +
  scale_alpha(guide = 'none') +
  scale_size(guide = 'none') +
  scale_color_manual(
    values = palette2,
    breaks = c("Male", "Female"),
    guide = "none") +
  coord_flip()

Age 12

dat %>%
  ggplot(
    mapping = aes(
    x = sex,
    y = isolation_combined_12,
    fill = sex)) +
  geom_hline(yintercept = 5, linetype = "dashed", color = "gray") +
  geom_hline(yintercept = 10, linetype = "dashed", color = "gray") +
  geom_hline(yintercept = 15, linetype = "dashed", color = "gray") +
  geom_flat_violin(
    position = position_nudge(x = .2, y = 0),
    trim = FALSE,
    alpha = 0.5
    ) +
  geom_point(
    aes(
      y = isolation_combined_05,
      color = sex),
    position = position_jitter(width = .15),
    size = .5,
    alpha = 0.8) +
 stat_summary(fun = mean,
              fun.min = function(x) mean(x)* sd(x),
              fun.max = function(x) mean(x) + sd(x),
              geom = "pointrange"
              ) +
  labs(
    title = "Social isolation in males and females at age 12",
    y = "Social isolation",
    fill = "Sex") +
  theme_personal +
  theme(
    axis.text.y = element_blank()
  ) +
  scale_fill_manual(
    values = palette2,
    breaks = c("Male", "Female")
) +
  scale_alpha(guide = 'none') +
  scale_size(guide = 'none') +
  scale_color_manual(
    values = palette2,
    breaks = c("Male", "Female"),
    guide = "none") +
  coord_flip()

 

Work by Katherine N Thompson

katherine.n.thompson@kcl.ac.uk