! tetrachoric.mx ! estimating tetrachoric correlations #define nvar 1 #define maxthresf 1 ! number of thresholds Analysis of depression data: estimating tetrachorics & confidence intervals data NI=3 NO=2 NG=4 LAbels twina twinb countmz Ordinal fi=depmzf.rec ! Count is a definition variable that we use to tell MX the frequency count ! for each element of the 2x2 table ! Definition_variables countmz / Begin matrices; W LO nvar nvar fr ! w*w' is the tetrachoric correlation Y LO nvar nvar fr ! y*y' is 1-tetrachoric correlation M FU maxthresf nvar fi S DI nvar nvar ! Matrix that will store weight variable end matrices; SP M 3 MATRIX M 1.5487 ! This tells MX to store the definition variable count in S SP S -1 mat w 0.7 mat y 0.7 Begin algebra; R=W*W'; E=Y*Y'; V=R+E; end algebra; FREQ S; ! tells MX that S contains the weight (frequency) variable TH M|M; ! tells MX that row and column thresholds contained in M_M CO V|R_R'|V; ! formula for correlation matrix! bo 0.001 1.0 y(1,1) bo 0.0001 0.999 w(1,1) bo -5.0 5.0 m(1,1) interval r(1,1) ! compute 95% confidence interval for correlation OPT func=1.E-12 OPT RS END Analysis of ordinal data: DZm data NI=3 NO=4 LAbels twina twinb countdz OR fi=depdzf.rec Definition_variables countdz / Begin matrices; W LO nvar nvar fr ! w*w' is the tetrachoric correlation for DZ group Y LO nvar nvar fr ! y*y' is 1-tetrachoric correlation for DZ group N FU maxthresf nvar fr S DI nvar nvar ! Matrix that will store weight variable end matrices; SP N 6 MATRIX N 1.4487 SP S -1 mat w 0.6 mat y 0.8 Begin algebra; R=W*W'; E=Y*Y'; V=R+E; end algebra; FREQ S; TH N|N; CO V|R_R'|V; bo 0.001 1.0 y(1,1) bo 0.0001 0.999 w(1,1) bo -5.0 5.0 n(1,1) interval r(1,1) ! compute 95% confidence interval for correlation OPT RS END Constraint function - constrain variances to unity for MZ group CO NI=1 Begin matrices = group 1; U unit 1 nvar end matrices; CO \d2v(V) = u; end Constraint function - constrain variances to unity for DZ group CO NI=1 Begin matrices = group 2; U unit 1 nvar end matrices; CO \d2v(V) = u; end