#code to test for significance of indirect effects. #Only indirect effects in which a (stressor to RQ or NRI) and b (NRI or RQ to health) paths were significant were tested #See for explanation of syntax: Selig, J. P., & Preacher, K. J. (2008, June). Monte Carlo method for assessing mediation: An interactive tool for creating confidence intervals for indirect effects [Computer software]. #Available from http://quantpsy.org/medmc/medmc.htm #code for actor, actor indirect effect of internalized stigma on depression via NRI require(MASS) a=0.29 b=1.92 rep=20000 conf=95 pest=c(a,b) acov <- matrix(c(0.00868286,0.000130347,0.000130347,0.498833),2,2)#matrix includes (variance[a],covariance[a,b],covariance[a,b],variance[b]) - retrieved from tech 1 and tech3 in mplus output mcmc <- mvrnorm(rep,pest,acov,empirical=FALSE) ab <- mcmc[,1]*mcmc[,2] low=(1-conf/100)/2 upp=((1-conf/100)/2)+(conf/100) LL=quantile(ab,low) UL=quantile(ab,upp) LL4=format(LL,digits=4) UL4=format(UL,digits=4) hist(ab,breaks='FD',col='skyblue',xlab=paste(conf,'% Confidence Interval ','LL',LL4,' UL',UL4), main='Distribution of Indirect Effect') #code for actor, actor indirect effect of microaggressions on depression via NRI require(MASS) a=0.3 b=2.95 rep=20000 conf=95 pest=c(a,b) acov <- matrix(c(0.00578866,-0.00758832,-0.00758832,0.748605),2,2) mcmc <- mvrnorm(rep,pest,acov,empirical=FALSE) ab <- mcmc[,1]*mcmc[,2] low=(1-conf/100)/2 upp=((1-conf/100)/2)+(conf/100) LL=quantile(ab,low) UL=quantile(ab,upp) LL4=format(LL,digits=4) UL4=format(UL,digits=4) hist(ab,breaks='FD',col='skyblue',xlab=paste(conf,'% Confidence Interval ','LL',LL4,' UL',UL4), main='Distribution of Indirect Effect') #code for actor, actor indirect effect of internalized stigma on AUDIT via NRI require(MASS) a=0.29 b=1.12 rep=20000 conf=95 pest=c(a,b) acov <- matrix(c(0.00862197,-0.0000139982,-0.0000139982,0.225422),2,2) mcmc <- mvrnorm(rep,pest,acov,empirical=FALSE) ab <- mcmc[,1]*mcmc[,2] low=(1-conf/100)/2 upp=((1-conf/100)/2)+(conf/100) LL=quantile(ab,low) UL=quantile(ab,upp) LL4=format(LL,digits=4) UL4=format(UL,digits=4) hist(ab,breaks='FD',col='skyblue',xlab=paste(conf,'% Confidence Interval ','LL',LL4,' UL',UL4), main='Distribution of Indirect Effect') #code for actor, actor indirect effect of microaggressions on AUDIT via NRI require(MASS) a=0.3 b=.86 rep=20000 conf=95 pest=c(a,b) acov <- matrix(c(0.00612348,-0.00560038,-0.00560038,0.156549),2,2) mcmc <- mvrnorm(rep,pest,acov,empirical=FALSE) ab <- mcmc[,1]*mcmc[,2] low=(1-conf/100)/2 upp=((1-conf/100)/2)+(conf/100) LL=quantile(ab,low) UL=quantile(ab,upp) LL4=format(LL,digits=4) UL4=format(UL,digits=4) hist(ab,breaks='FD',col='skyblue',xlab=paste(conf,'% Confidence Interval ','LL',LL4,' UL',UL4), main='Distribution of Indirect Effect')