Example of Stata Do-File Created by Andy Lin based on Selya et al. 2012 (Frontiers in Psychology 3:111). Dependent variable is the absolute value of the difference (abs_diff) between LSRP and LORP scores on the same psychopathy factor (here, primary psychopathy) for the same judge and the same target individual. Predictors are the judge's general trust (gen_trust), the target's LSRP score for that factor (lsrp_standardized), and their interaction. Condition is 1 (video with full audio). Model output includes parameter estimates for fixed effects, parameter variance of random effects (judge_id and target_id), and effect size estimates for the fixed effects. *run full model meglm abs_diff c.gen_trust##c.lsrp_standardized if psychopathy_factor==1 & condition==1 || _all: R.judge_id || target_id: *save residual variance global Vab = _b[var(e.abs_diff):_cons] *save random effects *will constrain random effects in reduced model and null model to be equal to the random * effects in the full model matrix judge_id_re = _b[var(_cons[_all>r_id]):_cons] matrix target_id_re = _b[var(_cons[t_id]):_cons] *run reduced model * the "cov()" options are constraining the random effects to be equal to those in the full model meglm abs_diff lsrp_standardized gen_trust if psychopathy_factor==1 & condition==1 || _all: R.judge_id, cov(fixed(judge_id_re)) || target_id:, cov(fixed(target_id_re)) *save residual variance of reduced model global Va = _b[var(e.abs_diff):_cons] *run null model (no predictors) with constrained random effects meglm abs_diff if psychopathy_factor==1 & condition==1 || _all: R.judge_id, cov(fixed(judge_id_re)) || target_id:, cov(fixed(target_id_re)) *get residual variance of null model global Vnull = _b[var(e.abs_diff):_cons] display "Residual variance full model = $Vab" display "Residual variance reduced model = $Va" display "Residual variance null model = $Vnull" *R-squared here is defined as reduction in unexplained variance (i.e. reduction in residual), * due to all predictor in model *R-squared for full model global R2ab = ($Vnull - $Vab)/$Vnull display "R-squared full model = $R2ab" *R-squared for reduced model global R2a = ($Vnull - $Va)/$Vnull display "R-squared reduced model = $R2a" *effect size *numerator is additional proportion of variance explained in outcome by predictors added to * reduced model to make full model *denominator is proportion of variance unexplained by full model *so, effect size is how much additional variance explained by predictor relative to amount of unexplained variance global f2b=($R2ab - $R2a)/(1-$R2ab) display "effect size interaction = $f2b"