------------------------------------------------------------------------------------------------------------- name: log: D:\stovring\SDCA\EpiSpace_EpiStats\Analysis_of_Change\bl_change_ancova.log log type: text opened on: 31 Aug 2023, 12:31:44 . . clear . set seed 5158887 . . . ***************************************************************************** . * Values controlling the setting . scalar dx = - 0.0 // baseline average difference . scalar eff_size = .7 // Effect size at follow-up . . mat m1 = (25, 25) // BMI at baseline and follow-up (control group) . mat covmat = (5, 4.5 \ 4.5, 5) // Covariance BL vs FU (high correlation) . . . ***************************************************************************** . * Creating simulated dataset . drawnorm bl_x1 fu_y1, n(300) means(m1) cov(covmat) (obs 300) . . mat m2 = (25 + dx, 25 + dx + eff_size) . drawnorm bl_x2 fu_y2, n(300) means(m2) cov(covmat) . . gen id = _n . reshape long bl_x fu_y, i(id) j(group) (j = 1 2) Data Wide -> Long ----------------------------------------------------------------------------- Number of observations 300 -> 600 Number of variables 5 -> 4 j variable (2 values) -> group xij variables: bl_x1 bl_x2 -> bl_x fu_y1 fu_y2 -> fu_y ----------------------------------------------------------------------------- . . . ***************************************************************************** . * Assessment of baseline balance . ttest bl_x, by(group) Two-sample t test with equal variances ------------------------------------------------------------------------------ Group | Obs Mean Std. err. Std. dev. [95% conf. interval] ---------+-------------------------------------------------------------------- 1 | 300 24.86663 .1306142 2.262304 24.60959 25.12367 2 | 300 25.00708 .1306577 2.263058 24.74995 25.2642 ---------+-------------------------------------------------------------------- Combined | 600 24.93685 .092341 2.261884 24.7555 25.1182 ---------+-------------------------------------------------------------------- diff | -.1404497 .1847471 -.5032818 .2223824 ------------------------------------------------------------------------------ diff = mean(1) - mean(2) t = -0.7602 H0: diff = 0 Degrees of freedom = 598 Ha: diff < 0 Ha: diff != 0 Ha: diff > 0 Pr(T < t) = 0.2237 Pr(|T| > |t|) = 0.4474 Pr(T > t) = 0.7763 . . . ***************************************************************************** . * SACS . gen diff = fu_y - bl_x . ttest diff, by(group) Two-sample t test with equal variances ------------------------------------------------------------------------------ Group | Obs Mean Std. err. Std. dev. [95% conf. interval] ---------+-------------------------------------------------------------------- 1 | 300 -.0345776 .0568587 .9848214 -.1464715 .0773163 2 | 300 .6970288 .0615253 1.065649 .5759513 .8181062 ---------+-------------------------------------------------------------------- Combined | 600 .3312256 .0444413 1.088586 .2439458 .4185053 ---------+-------------------------------------------------------------------- diff | -.7316064 .0837751 -.8961356 -.5670772 ------------------------------------------------------------------------------ diff = mean(1) - mean(2) t = -8.7330 H0: diff = 0 Degrees of freedom = 598 Ha: diff < 0 Ha: diff != 0 Ha: diff > 0 Pr(T < t) = 0.0000 Pr(|T| > |t|) = 0.0000 Pr(T > t) = 1.0000 . . . ***************************************************************************** . * ANCOVA . regress fu_y b1.group c.bl_x Source | SS df MS Number of obs = 600 -------------+---------------------------------- F(2, 597) = 1283.06 Model | 2555.08405 2 1277.54203 Prob > F = 0.0000 Residual | 594.43213 597 .99569871 R-squared = 0.8113 -------------+---------------------------------- Adj R-squared = 0.8106 Total | 3149.51618 599 5.2579569 Root MSE = .99785 ------------------------------------------------------------------------------ fu_y | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- 2.group | .7466462 .0815132 9.16 0.000 .5865587 .9067338 bl_x | .8929168 .0180339 49.51 0.000 .8574991 .9283344 _cons | 2.628221 .452128 5.81 0.000 1.740266 3.516176 ------------------------------------------------------------------------------ . . log close name: log: D:\stovring\SDCA\EpiSpace_EpiStats\Analysis_of_Change\bl_change_ancova.log log type: text closed on: 31 Aug 2023, 12:31:45 -------------------------------------------------------------------------------------------------------------