Skip to content

Instantly share code, notes, and snippets.

@katiefinning1
Created February 28, 2022 17:16
Show Gist options
  • Save katiefinning1/0e61c71eb74c3032805adad1477149ca to your computer and use it in GitHub Desktop.
Save katiefinning1/0e61c71eb74c3032805adad1477149ca to your computer and use it in GitHub Desktop.
Stata do-file for analysis of the association between socioeconomic status and child mental health in the STARS randomised controlled trial
/*
---------------------------------------------------------------------------
-- Socioeconomic status and child mental health in the STARS trial
-- Analysis using Stata/SE 15.0
-- Do-file written by Katie Finning
-- June 2020
---------------------------------------------------------------------------
*/
use "C:\Users\Data\SES and mental health in STARS - cleaned 09_07_2020.dta", ///
replace
log using "Main analysis.log", replace
fvset base 5 IMDQuint /*Set base value of IMD to quintile 5 (least deprived) */
* ---------------------------------------------------------------------------
* DESCRIPTIVE ANALYSIS
* T0 - Baseline
tab IMDQuint, sum(ttotal0) /*Summaries for teacher total difficulties*/
oneway ttotal0 IMDQuint /*One-way ANOVA for teacher total difficulties*/
tab IMDQuint, sum(ptotal0) /*Summaries for parent total difficulties*/
oneway ptotal0 IMDQuint /*One-way ANOVA for parent total difficulties*/
tab anydiag0 IMDQuint, col chi2 /*Tab and chi-square for probable disorder*/
* T2 - 18 months
tab IMDQuint, sum(ttotal2)
oneway ttotal2 IMDQuint
tab IMDQuint, sum(ptotal2)
oneway ptotal2 IMDQuint
tab anydiag2 IMDQuint, col chi2
* T3 - 30 months
tab IMDQuint, sum(ttotal3)
oneway ttotal3 IMDQuint
tab IMDQuint, sum(ptotal3)
oneway ptotal3 IMDQuint
tab anydiag3 IMDQuint, col chi2
* ------------------------------------------------------------------------------
* MAIN ANALYSES USING COMPLETE CASES
* Tests of interaction
* Interaction effect for trial arm at baseline
mixed ttotal0 i.IMDQuint##i.Allocation || Cluster:
testparm i.IMDQuint#i.Allocation
mixed ttotal0 i.IMDQuint##Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster:
testparm i.IMDQuint#i.Allocation
mixed ptotal0 i.IMDQuint##i.Allocation || Cluster:
testparm i.IMDQuint#i.Allocation
mixed ptotal0 i.IMDQuint##i.Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster:
testparm i.IMDQuint#i.Allocation
melogit anydiag0 i.IMDQuint##Allocation || Cluster: , or
testparm i.IMDQuint#i.Allocation
melogit anydiag0 i.IMDQuint##Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster: , or
testparm i.IMDQuint#i.Allocation
/* None of the tests of interaction for trial arm are significant, either in
unadjusted or adjusted models */
* Interaction effect for year group at baseline
mixed ttotal0 i.IMDQuint##i.Year || Cluster:
testparm i.IMDQuint#i.Year
mixed ttotal0 i.IMDQuint##i.Year RecruitmentAgeYears Gender ChildEthnic_bin ///
|| Cluster:
testparm i.IMDQuint#i.Year
mixed ptotal0 i.IMDQuint##i.Year || Cluster:
testparm i.IMDQuint#i.Year
mixed ptotal0 i.IMDQuint##i.Year RecruitmentAgeYears Gender ChildEthnic_bin ///
|| Cluster:
testparm i.IMDQuint#i.Year
melogit anydiag0 i.IMDQuint##i.Year || Cluster: , or
testparm i.IMDQuint#i.Year
melogit anydiag0 i.IMDQuint##i.Year RecruitmentAgeYears Gender ChildEthnic_bin ///
|| Cluster:, or
testparm i.IMDQuint#i.Year
/* None of the tests of interaction for year group are significant, either in
unadjusted or adjusted models */
* Re-shape data to long
reshape long ttotal@ ptotal@ anydiag@, i(StudyNumber) j(time)
rename time months
recode months (0=0) (2=18) (3=30)
* Interaction effect for year group across all time-points
mixed ttotal i.IMDQuint##i.Year i.months || Cluster: || StudyNumber:
testparm i.IMDQuint#i.Year
mixed ttotal i.IMDQuint##i.Year i.months RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster: || StudyNumber:
testparm i.IMDQuint#i.Year
mixed ptotal i.IMDQuint##i.Year i.months || Cluster: || StudyNumber:
testparm i.IMDQuint#i.Year
mixed ptotal i.IMDQuint##i.Year i.months RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster: || StudyNumber:
testparm i.IMDQuint#i.Year
melogit anydiag i.IMDQuint##i.Year i.months || Cluster: , or
testparm i.IMDQuint#i.Year
melogit anydiag i.IMDQuint##i.Year i.months RecruitmentAgeYears Gender ///
ChildEthnic_bin , vce(cluster Cluster) or
testparm i.IMDQuint#i.Year
* ---------------------------------------------------------------------------
* INITIAL TESTING OF MULTI-LEVEL MODELS
/* Testing if null multi-level model with no predictors is superior fit to
single-level model */
mixed ttotal /*single-level model*/
estimates store single
mixed ttotal || Cluster: /*basic multi-level model with no predictors*/
estimates store multi
lrtest single multi
mixed ttotal || Cluster: || StudyNumber:
estimates store three
lrtest multi three
/* Shows there is clustering at school level and at child level, therefore
multi-level better fit than standard regression */
* Examine if effect of IMD on ttotal differs by school
mixed ttotal i.IMDQuint || Cluster:
estimates store a
mixed ttotal i.IMDQuint || Cluster: IMDQuint
estimates store b
lrtest a b
/* Likelihood ratio test is significant (p=.004) showing IMD effect varies
by school, hence allow random slopes at level 2 */
*Examine if effect of IMD on ttotal differs across repeated measures
mixed ttotal i.IMDQuint || Cluster: IMDQuint || StudyNumber:
estimates store c
mixed ttotal i.IMDQuint || Cluster: IMDQuint || StudyNumber: IMDQuint
estimates store d
lrtest c d
/* LR test not significant (p=.99), so no need to allow for random slopes at
repeated measures level, which is what we would expect */
* ---------------------------------------------------------------------------
* UNADJUSTED MULTI-LEVEL MODELS ACROSS ALL TIME-POINTS
char IMDQuint [omit]5
xi: mixed ttotal i.IMDQuint || Cluster: R.IMDQuint || StudyNumber:
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xi: mixed ptotal i.IMDQuint || Cluster: R.IMDQuint || StudyNumber:
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xtset Cluster
xi: xtlogit anydiag i.IMDQuint, vce(cluster Cluster) or
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
* ---------------------------------------------------------------------------
*ADJUSTED MULTI-LEVEL MODELS ACROSS ALL TIME POINTS
xi: mixed ttotal i.IMDQuint Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster: R.IMDQuint || StudyNumber:
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xi: mixed ptotal i.IMDQuint Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster: R.IMDQuint || StudyNumber:
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xtset Cluster
xi: xtlogit anydiag i.IMDQuint Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin, vce(cluster Cluster) or
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
* ---------------------------------------------------------------------------
* TESTS FOR INTERACTION BY TIME-POINT
* Unadjusted
mixed ttotal i.IMDQuint##i.months || Cluster: R.IMDQuint
testparm i.IMDQuint#i.months
mixed ptotal i.IMDQuint##i.months || Cluster: R.IMDQuint
testparm i.IMDQuint#i.months
xtlogit anydiag i.IMDQuint##i.months, vce(cluster Cluster) or
testparm i.IMDQuint#i.months
* Adjusted
mixed ttotal i.IMDQuint##i.months Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster: R.IMDQuint
testparm i.IMDQuint#i.months
mixed ptotal i.IMDQuint##i.months Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster: R.IMDQuint
testparm i.IMDQuint#i.months
xtlogit anydiag i.IMDQuint##i.months Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin, vce(cluster Cluster) or
testparm i.IMDQuint#i.months
/* Time is a significant moderator for both ttotal and anydiag, in both adjusted
and unadjusted models, so we will perform subgroup analyses by time-point */
* ---------------------------------------------------------------------------
*SUBGROUP ANALYSES BY TIME - UNADJUSTED
* Teacher total difficulties scores
xi: mixed ttotal i.IMDQuint || Cluster: R.IMDQuint if months ==0
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xi: mixed ttotal i.IMDQuint || Cluster: R.IMDQuint if months ==18
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xi: mixed ttotal i.IMDQuint || Cluster: R.IMDQuint if months ==30
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
* Parent total difficulties scores
xi: mixed ptotal i.IMDQuint || Cluster: R.IMDQuint if months ==0
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xi: mixed ptotal i.IMDQuint || Cluster: R.IMDQuint if months==18
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xi: mixed ptotal i.IMDQuint || Cluster: R.IMDQuint if months ==30
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
* Probable psychiatric disorder
xi: melogit anydiag i.IMDQuint if months ==0 || Cluster: R.IMDQuint , or
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xi: melogit anydiag i.IMDQuint if months ==18 || Cluster: R.IMDQuint, or
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xi: melogit anydiag i.IMDQuint if months ==30 || Cluster: R.IMDQuint, or
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
* ---------------------------------------------------------------------------
* SUBGROUP ANALYSES BY TIME - ADJUSTED
* Teacher total difficulties scores
xi: mixed ttotal i.IMDQuint Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster: R.IMDQuint if months==0
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xi: mixed ttotal i.IMDQuint Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster: R.IMDQuint if months==18
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xi: mixed ttotal i.IMDQuint Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster: R.IMDQuint if months==30
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
* Parent total difficulties scores
xi: mixed ptotal i.IMDQuint Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster: R.IMDQuint if months==0
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xi: mixed ptotal i.IMDQuint Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster: R.IMDQuint if months==18
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xi: mixed ptotal i.IMDQuint Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin || Cluster: R.IMDQuint if months==30
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
* Probable psychiatric disorder
xi: melogit anydiag i.IMDQuint Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin if months==0 || Cluster: R.IMDQuint, or
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xi: melogit anydiag i.IMDQuint Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin if months==18 || Cluster: R.IMDQuint, or
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
xi: melogit anydiag i.IMDQuint Allocation RecruitmentAgeYears Gender ///
ChildEthnic_bin if months==30 || Cluster: R.IMDQuint , or
test _IIMDQuint_1 _IIMDQuint_2 _IIMDQuint_3 _IIMDQuint_4
* ---------------------------------------------------------------------------
* MAIN ANALYSES USING MULTIPLY IMPUTED DATASET
* Load imputed data
use "C:\Users\Data\SES and mental health in STARS - imputed.dta", replace
* Passively create interaction terms:
mi passive: generate IMDxYear = IMDQuint*Year
* Set base value of IMD to Quintile 5
mi fvset base 5 IMDQuint
* Reshape data to long
mi reshape long ttotal ptotal anydiag, i(StudyNumber) j(time)
rename time months
recode months (0=0) (2=18) (3=30)
mi xtset Cluster
/* Create a re-coded version of IMD Quintile such that quintile 1 = quintile 5,
and vice versa, because I can't use any of the commands I know (fvset, omit)
with mi in order to tell Stata to use Q5 (rather than Q1) as the comparator
group */
mi passive: generate IMDQuint_rev = 1 if IMDQuint==5
mi passive: replace IMDQuint_rev = 2 if IMDQuint==4
mi passive: replace IMDQuint_rev = 3 if IMDQuint==3
mi passive: replace IMDQuint_rev = 4 if IMDQuint==2
mi passive: replace IMDQuint_rev = 5 if IMDQuint==1
* ---------------------------------------------------------------------------
* UNADJUSTED MULTI-LEVEL MODELS ACROSS ALL TIME-POINTS
/* Have to use meqrlogit as melogit doesn't work with mi estimate
meqrlogit wouldn't converge; using xtlogit instead which can only account for
one level of clustering. We compared the ttotal and ptotal models using "mixed"
with (a) school + child clustering, and (b) school clustering only, and results
were similar. So we are using xtlogit for the anydiag outcome variable and
adjusting for school clustering only */
xi: mi estimate: mixed ttotal i.IMDQuint_rev || Cluster: R.IMDQuint_rev || ///
StudyNumber:
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: mixed ptotal i.IMDQuint_rev || Cluster: R.IMDQuint_rev || ///
StudyNumber:
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: xtlogit anydiag i.IMDQuint_rev, vce(cluster Cluster) or
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
* ---------------------------------------------------------------------------
* ADJUSTED MULTI-LEVEL MODELS ACROSS ALL TIME-POINTS
xi: mi estimate: mixed ttotal i.IMDQuint_rev Allocation RecruitmentAgeYears ///
Gender ChildEthnic_bin || Cluster: R.IMDQuint_rev || StudyNumber:
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: mixed ptotal i.IMDQuint_rev Allocation RecruitmentAgeYears ///
Gender ChildEthnic_bin || Cluster: R.IMDQuint_rev || StudyNumber: , ///
emtolerance(30)
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: xtlogit anydiag i.IMDQuint_rev Allocation RecruitmentAgeYears ///
Gender ChildEthnic_bin, vce(cluster Cluster) or
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
* ---------------------------------------------------------------------------
* TESTING INTERACTION EFFECT FOR TRIAL ARM ACROSS ALL TIME-POINTS
* Unadjusted
xi: mi estimate: mixed ttotal i.IMDQuint_rev*i.Allocation || ///
Cluster: R.IMDQuint_rev
mi test _IIMDXAll_2_1 _IIMDXAll_3_1 _IIMDXAll_4_1 _IIMDXAll_5_1
xi: mi estimate: mixed ptotal i.IMDQuint_rev*i.Allocation || ///
Cluster: R.IMDQuint_rev
mi test _IIMDXAll_2_1 _IIMDXAll_3_1 _IIMDXAll_4_1 _IIMDXAll_5_1
xi: mi estimate: xtlogit anydiag i.IMDQuint_rev*i.Allocation, ///
vce (cluster Cluster)
mi test _IIMDXAll_2_1 _IIMDXAll_3_1 _IIMDXAll_4_1 _IIMDXAll_5_1
* Adjusted
xi: mi estimate: mixed ttotal i.IMDQuint_rev*i.Allocation RecruitmentAgeYears ///
Gender ChildEthnic_bin || Cluster: R.IMDQuint_rev
mi test _IIMDXAll_2_1 _IIMDXAll_3_1 _IIMDXAll_4_1 _IIMDXAll_5_1
xi: mi estimate: mixed ptotal i.IMDQuint_rev*i.Allocation RecruitmentAgeYears ///
Gender ChildEthnic_bin || Cluster: R.IMDQuint_rev
mi test _IIMDXAll_2_1 _IIMDXAll_3_1 _IIMDXAll_4_1 _IIMDXAll_5_1
xi: mi estimate: xtlogit anydiag i.IMDQuint_rev*i.Allocation ///
RecruitmentAgeYears Gender ChildEthnic_bin, vce (cluster Cluster)
mi test _IIMDXAll_2_1 _IIMDXAll_3_1 _IIMDXAll_4_1 _IIMDXAll_5_1
* ---------------------------------------------------------------------------
* TESTING INTERACTION EFFECT FOR YEAR GROUP ACROSS ALL TIME-POINTS
* Unadjusted
xi: mi estimate: mixed ttotal i.IMDQuint_rev*i.Year || Cluster: R.IMDQuint_rev
mi test _IIMDXYea_2_1 _IIMDXYea_2_2 _IIMDXYea_2_3 _IIMDXYea_2_4 _IIMDXYea_3_1 ///
_IIMDXYea_3_2 _IIMDXYea_3_3 _IIMDXYea_3_4 _IIMDXYea_4_1 _IIMDXYea_4_2 ///
_IIMDXYea_4_3 _IIMDXYea_4_4 _IIMDXYea_5_1 _IIMDXYea_5_2 _IIMDXYea_5_3 ///
_IIMDXYea_5_4
xi: mi estimate: mixed ptotal i.IMDQuint_rev*i.Year || Cluster: R.IMDQuint_rev
mi test _IIMDXYea_2_1 _IIMDXYea_2_2 _IIMDXYea_2_3 _IIMDXYea_2_4 _IIMDXYea_3_1 ///
_IIMDXYea_3_2 _IIMDXYea_3_3 _IIMDXYea_3_4 _IIMDXYea_4_1 _IIMDXYea_4_2 ///
_IIMDXYea_4_3 _IIMDXYea_4_4 _IIMDXYea_5_1 _IIMDXYea_5_2 _IIMDXYea_5_3 ///
_IIMDXYea_5_4
xi: mi estimate: xtlogit anydiag i.IMDQuint_rev*i.Year, vce(cluster Cluster)
mi test _IIMDXYea_2_1 _IIMDXYea_2_2 _IIMDXYea_2_3 _IIMDXYea_2_4 _IIMDXYea_3_1 ///
_IIMDXYea_3_2 _IIMDXYea_3_3 _IIMDXYea_3_4 _IIMDXYea_4_1 _IIMDXYea_4_2 ///
_IIMDXYea_4_3 _IIMDXYea_4_4 _IIMDXYea_5_1 _IIMDXYea_5_2 _IIMDXYea_5_3 ///
_IIMDXYea_5_4
* Adjusted
xi: mi estimate: mixed ttotal i.IMDQuint_rev*i.Year Allocation ///
RecruitmentAgeYears Gender ChildEthnic_bin || Cluster: R.IMDQuint_rev
mi test _IIMDXYea_2_1 _IIMDXYea_2_2 _IIMDXYea_2_3 _IIMDXYea_2_4 _IIMDXYea_3_1 ///
_IIMDXYea_3_2 _IIMDXYea_3_3 _IIMDXYea_3_4 _IIMDXYea_4_1 _IIMDXYea_4_2 ///
_IIMDXYea_4_3 _IIMDXYea_4_4 _IIMDXYea_5_1 _IIMDXYea_5_2 _IIMDXYea_5_3 ///
_IIMDXYea_5_4
xi: mi estimate: mixed ptotal i.IMDQuint_rev*i.Year Allocation
RecruitmentAgeYears Gender ChildEthnic_bin || Cluster: R.IMDQuint_rev
mi test _IIMDXYea_2_1 _IIMDXYea_2_2 _IIMDXYea_2_3 _IIMDXYea_2_4 _IIMDXYea_3_1 ///
_IIMDXYea_3_2 _IIMDXYea_3_3 _IIMDXYea_3_4 _IIMDXYea_4_1 _IIMDXYea_4_2 ///
_IIMDXYea_4_3 _IIMDXYea_4_4 _IIMDXYea_5_1 _IIMDXYea_5_2 _IIMDXYea_5_3 ///
_IIMDXYea_5_4
xi: mi estimate: xtlogit anydiag i.IMDQuint_rev*i.Year Allocation
RecruitmentAgeYears Gender ChildEthnic_bin , vce(cluster Cluster)
mi test _IIMDXYea_2_1 _IIMDXYea_2_2 _IIMDXYea_2_3 _IIMDXYea_2_4 _IIMDXYea_3_1 ///
_IIMDXYea_3_2 _IIMDXYea_3_3 _IIMDXYea_3_4 _IIMDXYea_4_1 _IIMDXYea_4_2 ///
_IIMDXYea_4_3 _IIMDXYea_4_4 _IIMDXYea_5_1 _IIMDXYea_5_2 _IIMDXYea_5_3 ///
_IIMDXYea_5_4
* Year group not a moderator across all time-points; no need to stratify by Year
* ---------------------------------------------------------------------------
* TEST FOR INTERACTION BY TIME-POINT
* Unadjusted
xi: mi estimate: mixed ttotal i.IMDQuint_rev*i.months || Cluster: R.IMDQuint_rev
mi test _IIMDXmon_2_18 _IIMDXmon_2_30 _IIMDXmon_3_18 _IIMDXmon_3_30
_IIMDXmon_4_18 _IIMDXmon_4_30 _IIMDXmon_5_18 _IIMDXmon_5_30
xi: mi estimate: mixed ptotal i.IMDQuint_rev*i.months || Cluster: R.IMDQuint_rev
mi test _IIMDXmon_2_18 _IIMDXmon_2_30 _IIMDXmon_3_18 _IIMDXmon_3_30
_IIMDXmon_4_18 _IIMDXmon_4_30 _IIMDXmon_5_18 _IIMDXmon_5_30
xi: mi estimate: xtlogit anydiag i.IMDQuint_rev*i.months, vce(cluster Cluster)
mi test _IIMDXmon_2_18 _IIMDXmon_2_30 _IIMDXmon_3_18 _IIMDXmon_3_30
_IIMDXmon_4_18 _IIMDXmon_4_30 _IIMDXmon_5_18 _IIMDXmon_5_30
* Adjusted
xi: mi estimate: mixed ttotal i.IMDQuint_rev*i.months Allocation
RecruitmentAgeYears Gender ChildEthnic_bin || Cluster: R.IMDQuint_rev
mi test _IIMDXmon_2_18 _IIMDXmon_2_30 _IIMDXmon_3_18 _IIMDXmon_3_30
_IIMDXmon_4_18 _IIMDXmon_4_30 _IIMDXmon_5_18 _IIMDXmon_5_30
xi: mi estimate: mixed ptotal i.IMDQuint_rev*i.months Allocation
RecruitmentAgeYears Gender ChildEthnic_bin || Cluster: R.IMDQuint_rev
mi test _IIMDXmon_2_18 _IIMDXmon_2_30 _IIMDXmon_3_18 _IIMDXmon_3_30
_IIMDXmon_4_18 _IIMDXmon_4_30 _IIMDXmon_5_18 _IIMDXmon_5_30
xi: mi estimate: xtlogit anydiag i.IMDQuint_rev*i.months Allocation
RecruitmentAgeYears Gender ChildEthnic_bin, vce(cluster Cluster)
mi test _IIMDXmon_2_18 _IIMDXmon_2_30 _IIMDXmon_3_18 _IIMDXmon_3_30
_IIMDXmon_4_18 _IIMDXmon_4_30 _IIMDXmon_5_18 _IIMDXmon_5_30
/* Time is a significant moderator for both ttotal and anydiag, in both adjusted
and unadjusted models (same as complete case analysis) */
* ---------------------------------------------------------------------------
* SUBGROUP ANALYSES BY TIME - UNADJUSTED
* Teacher total difficulties
xi: mi estimate: mixed ttotal i.IMDQuint_rev || Cluster: R.IMDQuint_rev
if months ==0
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: mixed ttotal i.IMDQuint_rev || Cluster: R.IMDQuint_rev
if months ==18
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: mixed ttotal i.IMDQuint_rev || Cluster: R.IMDQuint_rev
if months ==30
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
* Parent total difficulties
xi: mi estimate: mixed ptotal i.IMDQuint || Cluster: R.IMDQuint if months ==0
mi test _IIMDQuint_2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: mixed ptotal i.IMDQuint || Cluster: R.IMDQuint if months ==18
mi test _IIMDQuint_2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: mixed ptotal i.IMDQuint || Cluster: R.IMDQuint if months ==30
mi test _IIMDQuint_2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
* Probable disorder
xi: mi estimate: xtlogit anydiag i.IMDQuint_rev if months==0,
vce(cluster Cluster) or
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: xtlogit anydiag i.IMDQuint_rev if months==18,
vce(cluster Cluster) or
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: xtlogit anydiag i.IMDQuint_rev if months==30,
vce(cluster Cluster) or
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
* ---------------------------------------------------------------------------
* SUBGROUP ANALYSES BY TIME - ADJUSTED
* Teacher total difficulties
xi: mi estimate: mixed ttotal i.IMDQuint_rev Allocation RecruitmentAgeYears
Gender ChildEthnic_bin || Cluster: R.IMDQuint_rev if months==0
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: mixed ttotal i.IMDQuint_rev Allocation RecruitmentAgeYears
Gender ChildEthnic_bin || Cluster: R.IMDQuint_rev if months==18
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: mixed ttotal i.IMDQuint_rev Allocation RecruitmentAgeYears
Gender ChildEthnic_bin || Cluster: R.IMDQuint_rev if months==30
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
* Parent total difficulties
xi: mi estimate: mixed ptotal i.IMDQuint_rev Allocation RecruitmentAgeYears
Gender ChildEthnic_bin || Cluster: R.IMDQuint_rev if months==0
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: mixed ptotal i.IMDQuint_rev Allocation RecruitmentAgeYears
Gender ChildEthnic_bin || Cluster: R.IMDQuint_rev if months==18
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: mixed ptotal i.IMDQuint_rev Allocation RecruitmentAgeYears
Gender ChildEthnic_bin || Cluster: R.IMDQuint_rev if months==30
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
* Probable disorder
xi: mi estimate: xtlogit anydiag i.IMDQuint_rev Allocation RecruitmentAgeYears
Gender ChildEthnic_bin if months==0, vce(cluster Cluster) or
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: xtlogit anydiag i.IMDQuint_rev Allocation RecruitmentAgeYears
Gender ChildEthnic_bin if months==18, vce(cluster Cluster) or
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
xi: mi estimate: xtlogit anydiag i.IMDQuint_rev Allocation RecruitmentAgeYears
Gender ChildEthnic_bin if months==30, vce(cluster Cluster) or
mi test _IIMDQuint__2 _IIMDQuint__3 _IIMDQuint__4 _IIMDQuint__5
log close
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment