#The code here consists of three parts; # Part 1 is a function to compute the minimum tolerable size epsilon_0 as defined in equation (6) of the article #"Measurement Invariance via Multi-group SEM: Issues and Solutions with Chi-square-difference Tests" #by Ke-Hai Yuan and Wai Chan; #The corresponding noncentrality parameter (ncp) delta and RMSEA_0 are also calculated; # Part 2 is to generate the adjusted cutoff values for RMSEA; #corresponding to conventional cutoff values .01, .05, .08, and .10; #Part 3 illustrates how to use the functions in Part 1 and Part 2; ########################################################################################; #--------------------------------------------------------------------------------------#; #Part 1: This part is a function to compute the ncp delta=(N-m)*epsilon_0; #as well as the corresponding epsilon_0 and RMSEA_0; #The formula is from Venables 1975 for obtaining the noncentrality parameter #of a non-central chi-square distribution; #The inputs are significance level (alpha), observed statistic (T), degrees of freedom (df), # number of groups (m), and sample size (N); #------------------------do not change anything of this function-----------------------#; ncp_chi2=function(alpha,T,df,m,N_sample){ z=qnorm(1-alpha); N=N_sample; z2=z*z; z3=z2*z; z4=z3*z; z5=z4*z; sig2=2*(2*T-df+2); sig=sqrt(sig2); sig3=sig*sig2; sig4=sig2*sig2; sig5=sig4*sig; sig6=sig2*sig4; delta=T-df+2+sig* ( z+(z2-1)/sig-z/sig2 + 2*(df-1)*(z2-1)/(3*sig3) +( -(df-1)*(4*z3-z)/6+(df-2)*z/2 )/sig4 +4*(df-1)*(3*z4+2*z2-11)/(15*sig5) +( -(df-1)*(96*z5+164*z3-767*z)/90-4*(df-1)*(df-2)*(2*z3-5*z)/9 +(df-2)*z/2 )/sig6 ); delta=max(delta,0); epsilon_0=delta/(N-m); RMSEA_0=sqrt(m*epsilon_0/df); cat("noncentrality parameter ncp=", delta, "\n"); cat("minimum tolerable size=", epsilon_0, "\n"); cat("RMSEA_0 under equivalence testing=", RMSEA_0, "\n"); } ########################################################################################; #--------------------------------------------------------------------------------------#; #Part 2: This part is to generate adjusted cutoff values of RMSEA; #corresponding to conventional cutoff values .01, .05, .08, and .10; #The formula is based on the coefficients in Table 11 of the article; #The inputs are the number of groups (m), sample size (N_sample), and degrees of freedom (df); #------------------------do not change anything of this function-----------------------#; RMSEA_ctoa=function(m,N_sample,df){ RMSEA_cvec=c(.01,.05,.08,.10); RMSEA_avec=matrix(0,nrow=1,ncol=4); for (j in 1:4){ N=N_sample; RMSEA_c=RMSEA_cvec[j]; if (RMSEA_c==.01){ if (m==1){ n=N-m; y_e=1.34863-.51999*log(df)+.01925*log(df)*log(df)-.59811*log(n)+.00902*sqrt(n)+.01796*log(df)*log(n); }else if (m==2){ n=N-m; y_e=1.51409-.48929*log(df)+.01781*log(df)*log(df)-.53903*log(n)+.00005602*n+.01188*log(df)*log(n); }else if (m==3){ n=N-m; y_e=1.66291-.46885*log(df)+.01699*log(df)*log(df)-.52870*log(n)+.00004074*n+.00846*log(df)*log(n); }else if (m==4){ n=N-m; y_e=1.77502-.45735*log(df)+.01652*log(df)*log(df)-.52262*log(n)+.00003201*n+.00656*log(df)*log(n); }else if (m==5){ n=N-m; y_e=1.86574-.44997*log(df)+.01622*log(df)*log(df)-.51862*log(n)+.00002636*n+.00534*log(df)*log(n); } } if (RMSEA_c==.05){ if (m==1){ n=N-m; y_e=2.06034-.62974*log(df)+.02512*log(df)*log(df)-.98388*log(n)+.05442*log(n)*log(n)-.00005188*n+.05260*log(df)*log(n); }else if (m==2){ n=N-m; y_e=2.61777-.67451*log(df)+.02596*log(df)*log(df)-.99310*log(n)+.04739*log(n)*log(n)+.05331*log(df)*log(n); }else if (m==3){ n=N-m; y_e=2.98724-.67419*log(df)+.02566*log(df)*log(df)-1.03326*log(n)+.04855*log(n)*log(n)+.05022*log(df)*log(n); }else if (m==4){ n=N-m; y_e=1.98287-.66535*log(df)+.02518*log(df)*log(df)-.95007*log(n)+.71711*(n**(1/5))+.04695*log(df)*log(n); }else if (m==5){ n=N-m; y_e=2.12615-.65419*log(df)+.02468*log(df)*log(df)-.94634*log(n)+.69787*(n**(1/5))+.04390*log(df)*log(n); } } if (RMSEA_c==.08){ if (m==1){ n=N-m; y_e=2.84129-.54809*log(df)+.02296*log(df)*log(df)-.76005*log(n)+.10229*log(n)*log(n)-1.11167*(n**(1/5))+.04845*log(df)*log(n); }else if (m==2){ n=N-m; y_e=3.73383-.61834*log(df)+.02487*log(df)*log(df)-.93229*log(n)+.11073*log(n)*log(n)-1.09715*(n**(1/5))+.05296*log(df)*log(n); }else if (m==3){ n=N-m; y_e=2.91386-.65125*log(df)+.02563*log(df)*log(df)-1.09019*log(n)+.06789*log(n)*log(n)-.00948*sqrt(n)+.05430*log(df)*log(n); }else if (m==4){ n=N-m; y_e=3.04581-.66589*log(df)+.02588*log(df)*log(df)-1.05019*log(n)+.05572*log(n)*log(n)-.00003864*n+.05406*log(df)*log(n); }else if (m==5){ n=N-m; y_e=3.21990-.67182*log(df)+.02591*log(df)*log(df)-1.05668*log(n)+.05430*log(n)*log(n)-.00002718*n+.05314*log(df)*log(n); } } if (RMSEA_c==.10){ if (m==1){ n=N-m; y_e=2.36352-.49440*log(df)+.02131*log(df)*log(df)-.64445*log(n)+.09043*log(n)*log(n)-1.01634*(n**(1/5))+.04422*log(df)*log(n); }else if (m==2){ n=N-m; y_e=3.34834-.56888*log(df)+.02354*log(df)*log(df)-.81593*log(n)+.10506*log(n)*log(n)-1.10591*(n**(1/5))+.04962*log(df)*log(n); }else if (m==3){ n=N-m; y_e=3.90933-.61431*log(df)+.02476*log(df)*log(df)-.92236*log(n)+.11054*log(n)*log(n)-1.10284*(n**(1/5))+.05273*log(df)*log(n); }else if (m==4){ n=N-m; y_e=2.96570-.63962*log(df)+.02537*log(df)*log(df)-1.07005*log(n)+.06814*log(n)*log(n)-.01029*sqrt(n)+.05396*log(df)*log(n); }else if (m==5){ n=N-m; y_e=3.18941-.65440*log(df)+.02568*log(df)*log(df)-1.09231*log(n)+.06714*log(n)*log(n)-.00894*sqrt(n)+.05424*log(df)*log(n); } } RMSEA_avec[j]=exp(y_e); } result=cbind.data.frame(m,N_sample,df," ",RMSEA_avec); colnames(result)=c("m","N","df","cutoffs(", " .01 "," .05 "," .08 "," .10 )"); # return(result); print(result, row.names = FALSE) } ########################################################################################; #--------------------------------------------------------------------------------------#; #Part 3: Illustrations for computing epsilon_0 and the corresponding RMSEA_0, # as well as the adjusted cutoff values of RMSEA; #needed inputs are the observed statistics T_ml, its degrees of freedom (df), number of groups m, #and sample size for all the groups, as well as the level alpha; #-------------------configural invariance of Example 1 in the article------------------#; alpha=.05; N=200; m=1; T_ml=28.446; #the statistic T_ml for group 1; df=24; ncp=ncp_chi2(alpha=alpha, T=T_ml, df=df, m=m, N_sample=N); RMSEA_ctoa(m=m, N_sample=N, df=df); #-------------------metric invariance of Example 1 in the article------------------#; alpha=.05; N_1=200; N_2=200; N=N_1+N_2; m=2; T_ml=8.824; #the chi-square difference statistic; df=6; ncp=ncp_chi2(alpha=alpha, T=T_ml, df=df, m=m, N=N); RMSEA_ctoa(m=m, N_sample=N, df=df);