Study design and participants
This was a longitudinal cohort study linking TEDS survey data with administrative education records from NPD and Ofsted. Participants (N = 5,926, 54.1% female) are part of the TEDS, a population-based longitudinal study comprising over 13,000 families with twins born between 1994 and 1996. More than 10,000 twin pairs remain actively involved. The families in TEDS are representative of the British population for their birth cohort in terms of SES, ethnicity and parental occupation34.
Here, we used data from a subsample of twins (N = 5,926) who attend state schools in England who had consented to the use of their data held on the NPD (see Extended Data Fig. 1 for the sample selection flowchart from TEDS original sample through to the final analytic sample). As twin pairs are likely to attend the same school, we randomly selected one twin from each pair for analyses to control for the nonindependence of observations. Those who reported severe medical or neurological conditions were also excluded (N = 267). The sample size varied across time points, measures and reporters, but all available data were used. Observed sample sizes and percentage missingness for each variable are reported in Supplementary Tables 1–3.
Participants were distributed across 3,142 schools, with 68% of schools contributing only one participant. We calculated school-level intraclass correlations after restricting the sample to schools with at least two participating pupils. These indicated little clustering of psychopathology in schools, with less than 1% of variance in the p-factor attributable to between-school differences at ages 12, 16 and 21 (intraclass correlation coefficients of 0.007–0.009).
Using ANOVA, we compared family SES at first contact (~1.5 years) for TEDS participants who consented to the use of their NPD data with those who did not. We found that participants who consented had a significantly higher mean SES (mean of 0.2, s.d. of 0.99) than those who did not (mean of −0.2, s.d. of 0.97), although the effect was small (F(1, 23,682) = 963.9, P < 0.001, η2 = 0.039).
Ethics statement
Written informed consent for TEDS data collection was obtained from parents or legal guardians while participants were children, and from TEDS participants themselves for data collections carried out after participants reached adulthood. Linkage to participant-level NPD records was conducted only for TEDS participants for whom consent for administrative data linkage had been obtained. Ofsted inspection data were school-level administrative inspection records; individual participant consent was therefore not applicable to these data. The study was approved by King’s College London’s Ethics Committee for the Institute of Psychiatry, Psychology and Neuroscience (PNM/09/10-104).
Measures
Psychopathology
TEDS provides extensive data on emotional and behavioral traits from childhood through to early adulthood. In the present study, we used psychopathology data collected at ages 7, 12, 16 and 21 years. Traits were assessed using a battery of questionnaires completed by parents, teachers and participants themselves (see Supplementary Table 22 for a full list of measures). We used all mental health trait measures at each age point to calculate a theory-driven p-factor35,36 for each age group using CFA and FIML to account for missing data in lavaan for R (ref. 37). Participants received a standardized score based on this p-factor, indicating their relative level of psychopathology (high scores indicated a higher burden of psychopathology). We used CFA as a theory-driven data-reduction approach to derive a broad index of psychopathology burden across reporters and symptom domains, rather than to identify the best-fitting latent structure of psychopathology at each age. We retained all available mental health measures to preserve the breadth and comparability of the psychopathology measure across ages. This approach also allowed us to account for missing data in individual measures. All model fit statistics and factor loadings for p-factors at ages 7, 12, 16 and 21 are presented in Supplementary Table 7.
Administrative school environment measures
These measures were derived from two sources: the NPD and Ofsted inspection data. We use this term to refer to measures derived from administrative education records and external inspection data, rather than from pupil, parent or teacher reports within TEDS. These measures included school-level indicators, such as school composition, school-level attendance, headcount and Ofsted inspection ratings, as well as pupil-level attendance records. Pupil-level absence was included because the amount of time a pupil spends in school is a meaningful component of exposure to the school environment.
The NPD is an administrative dataset collected by the Department for Education on state-educated pupils in England born since 1986. This study linked data on pupil-level absenteeism, school-level absenteeism and school-level census data to participants in the TEDS sample (see Supplementary Table 23 for a full list of measures). Each participant was linked to the administrative school environment data relevant to the years in which they were 12 and 16 (see Supplementary Note 1 for full details of the data linkage process).
Additional measures are based on Ofsted inspection data collected between 2005 and 2015. Ofsted is the UK government office responsible for inspecting institutions that provide education and skills services, including all state-funded schools38. Multiple measures of school quality are publicly available, including ratings of teaching quality, student achievement and overall effectiveness. Inspectors rate each aspect of school quality on a 4-point scale (1: outstanding, 2: good, 3: satisfactory and 4: needs improvement), and given inspection ratings can determine the future governance of a school. The relevant Ofsted data for each TEDS participant at ages 12 and 16 were determined by selecting the closest inspections to 2005–2008 (when participants were 12 years old) and 2010–2013 (when participants were 16 years old). See Supplementary Table 23 for a full list of Ofsted measures.
Given the large number of administrative school environment measures, we conducted EFA and CFA to reduce the dimensionality of the data and address potential issues with multicollinearity. We performed EFA using psych for R on the administrative environmental measures available at age 16 in our sample. On the basis of the EFA results, we extracted and created latent factors of the administrative school environment at ages 12 and 16 using CFA in lavaan for R. This resulted in the creation of four latent factors measuring features of the administrative school environment: individual absence, school-level characteristics (including school quality ratings and school-level absenteeism), pupil community characteristics (including the proportion of children receiving FSM and with SEN) and headcount (including number of pupils and proportion of male and female students). FIML was used to account for data missingness (see Supplementary Tables 24 and 25 for full factor loadings and model fit statistics). Each participant was assigned a standardized score for each factor, indexing the individual administrative school environment they had experienced.
Perceived school environment measures
TEDS provides multiple measures of the school environment, including classroom environment, relationship with teachers, and homework, rated by parents, teachers and participants (see Supplementary Table 26 for a full list of subjective school environment measures). Measures were collected at ages 7, 9 and 16, but the measures differ across data collection waves. As with the administrative measures of school environment, we also conducted EFA and CFA to reduce the dimensionality of the data and address potential issues with multicollinearity. On the basis of the results of the EFA, we constructed four factors of the subjective school environment at age 9 (classroom environment (child report), classroom environment (parent report), feelings about school (parent and child report) and classroom attitude (teacher report)) and six factors at age 16 (teacher quality, classroom chaos, school satisfaction, school engagement, classroom peer relationships and subject attitudes). FIML was used to account for data missingness (see Supplementary Tables 27 and 28 for full factor loadings and model fit statistics). Each participant was assigned a standardized score on the basis of these factors, indexing the subjective school environment reported by their parent, teacher and themselves.
PGS
Genome-wide PGS were calculated for each participant to estimate individual genetic predisposition to psychiatric problems.
Genotyping was performed using one of two DNA microarrays (Affymetrix GeneChip 6.0 or Illumina HumanOmniExpressExome chips) according to standard protocols. DNA samples have been collected from 12,500 TEDS participants. Following rigorous quality control procedures, 10,346 samples were available for genomic analyses. Of them, 7,026 belonged to unrelated individuals, and 3,320 to additional dizygotic co-twins, with 7,289 individuals genotyped using Illumina arrays and 3,057 individuals genotyped with Affymetrix arrays. Further information on genotyping and quality control is detailed elsewhere39,40.
PGS were calculated to index genetic vulnerability to psychiatric problems using LDPred41. Details of the methods and analysis used are presented in earlier studies36,40. To construct the PGS, we used the genome-wide association summary statistics for 27 adult psychiatric disorders. We selected all mental health and mental health-related PGS available in TEDS that were constructed using well-powered genome-wide association studies. These were: attention deficit hyperactivity disorder42, anxiety43, anxious feeling/worrier43, autism spectrum disorder44, bipolar disorder45, multiple disorders: total child psychiatric problems46, daytime sleepiness47, depressive symptoms48, externalizing problems49, fed-up feelings50, guilty feelings50, insomnia51, irritability50, major depressive disorder52, miserableness50, mood swings50, nervous feelings50, neuroticism53, obsessive–compulsive disorder54, post-traumatic stress disorder55, risk-taking behavior50, risk tolerance56, schizophrenia57, sensitivity/hurt feelings50, sleep disorders50, subjective well-being48 and Tourette’s syndrome58. We used all PGS available in TEDS related to psychopathology.
SES
Family SES was assessed at first contact (when the twins were ~1.5 years old). Mothers and fathers reported their educational level, occupational status and mothers’ age at the birth of their first child. The composite of SES was computed as the mean of the standardized scores of these measures. SES was taken at first contact as this wave offers minimal missing data, and SES has been shown to be developmentally stable, with age-to-age correlations of ~0.70 (ref. 59).
Statistical analysis
Analyses were performed in R version 4.4.0.
Descriptive statistics and data preparation: we calculated descriptive statistics for all measures across all age collection waves, including the number of observed cases and percentage missingness for each variable. These are reported for mental health measures, administrative school environment measures and perceived school environment measures in Supplementary Tables 1–3. We conducted univariate ANOVA to explore phenotypic sex differences across measures. As significant sex differences emerged, all variables were adjusted for sex and age using linear regression. Age- and sex-adjusted standardized variables were used in all subsequent analyses.
p-Factor: we calculated a p-factor, that is, a general factor for psychopathology, for each age group, using CFA (‘Measures’).
Correlations: Pearson’s correlations were used to evaluate the cross-sectional associations between administrative school environment measures and psychopathology for each participant at ages 12 and 16, as well as the associations over time between the administrative school environment measures at 12 and mental health at 16, and administrative school environment measures at 12 and 16 and mental health at 21. We applied Benjamini–Hochberg false discovery rate correction (FDR) to account for multiple testing.
EFA and CFA: We applied EFA to the administrative school environment measures and the perceived school environment measures. On the basis of the results, we calculated latent factors of the administrative school environment measures and the perceived school environment measures using CFA (‘Measures’).
Covariate selection and sequential adjustment: covariates were selected a priori to account for plausible sources of confounding. Psychiatric PGS were included to account for genetic liability to mental health difficulties, given evidence that genetic influences contribute both to psychopathology and to environmental exposures21,22,23. Family SES was included because socioeconomic background is associated with both school context and child mental health15,16. Age 7 psychopathology was also included as a covariate to account for pre-existing mental health differences. Covariates were added sequentially to models to assess the extent to which associations were attenuated after accounting for genetic, socioeconomic and early mental health factors.
Cross-sectional models to predict psychopathology (p-factor) outcomes: we wanted to explore how well all administrative school environment measures combined explain psychopathology in childhood. We used multiple linear regression to determine the variance explained by the latent factors of the administrative school environment measures at age 12 in child psychopathology (p-factor) at age 12. We then used multiple linear regression to determine the variance explained by latent factors of the administrative school environment measures at age 16 in child psychopathology (p-factor) at age 16. We took a conservative approach and controlled both models for possible confounders in stages. First, we controlled for possible genetic confounding by using 27 adult psychiatric PGS. Then, we additionally controlled for family SES. Finally, in the fully adjusted model, we also controlled for early psychopathology (p-factor) at age 7. We reported the adjusted R2 for all adjusted and unadjusted models. We conducted a series of additional analyses to check for robustness: we repeated all multiple linear regression models using the administrative school environment measures without performing EFA and CFA. We also repeated the unadjusted models using penalized elastic net regression, a regularization technique that addresses issues with multicollinearity and overfitting60.
Longitudinal models to predict psychopathology (p-factor) outcomes: we wanted to explore how well all administrative school environment measures combined explain psychopathology across development. We used multiple linear regression to determine the variance explained by the latent factors of the administrative school environment measures at age 12 and 16 in child psychopathology (p-factor) at age 16. We then used multiple linear regression to determine the variance explained by latent factors of the administrative school environment measures at age 12 and 16 in child psychopathology (p-factor) at age 21. Again, we took a conservative approach, controlling, in stages, for 27 adult psychiatric PGS, family SES and early psychopathology (p-factor) at age 7. We reported the adjusted R2 for all adjusted and unadjusted models. As with the cross-sectional models, we repeated all unadjusted and adjusted models using the administrative school environment measures without performing EFA and CFA. We also repeated unadjusted models using penalized elastic net regression, a regularization technique that addresses issues with multicollinearity and overfitting60.
Cross-lagged panel analyses: a cross-lagged model examines relationships between the variables over time by specifying four types of pathways (See Extended Data Fig. 2): (1) the initial cross-sectional correlations that show the relationship between the variables in the first time point, (2) the stability effects that show how much each variable changes in response to its variability in the previous time point, (3) the cross-lagged effects that show how much each variable changes in response to the change of another variable in the previous time point and (4) the residual cross-sectional correlations that represent the relationship between the variables within each time point, that is not explained by the variables in the previous time points61,62. Thus the estimation of the longitudinal (cross-lagged) relationships between the latent factors of school environment and psychopathology accounted for stability of these variables over time.
The factors of school environment were added to p-factor one by one in the cross-lagged model, resulting in four models in total (Extended Data Fig. 2). Each model included two stability effects, two cross-lagged effects, and two cross-sectional correlations (one type a and one type d). The path estimates represented the strength of these effects, while their statistical significance was assessed using 95% CIs. The model did not include any parameter constraints. The random intercepts were not included in the model because they require at least three measurement occasions61.
Cross-sectional models to assess the joint prediction of school-level administrative and perceived school environment factors: we wanted to explore how well administrative school environment measures predicted psychopathology across development, accounting for the prediction of perceived school environment measures. We performed three ‘reduced’ multiple linear regression models—these assessed the effects of the perceived school environment only: in model one we examined the variance in the p-factor at age 12 explained by perceived school environment factors at age 9, as more contemporaneous measures were not available in TEDS. In model two, we assessed the variance in the p-factor at 16 explained by perceived school environment factors at age 16. In model three, we assessed the variance in the p-factor at 21 explained by perceived school environment factors at ages 9 and 16. We then re-ran each of the three models as ‘full’ models by additionally including school-level administrative factors (age 12 administrative factors to model one; age 16 administrative factors to model two; and age 12 and 16 administrative factors to model three). We calculated delta R2 values to compare variance explained by the perceived and administrative measures and performed likelihood ratio tests to establish whether the ‘full’ models provide a significantly better fit than the ‘reduced’ models.
Reporting summary
Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article.
