Home‎ > ‎Applied Analysis Notes‎ > ‎

### Applied Analysis Note 4

 * Example MPLUS code that generates parameter* estimates rounded to 2 decimal places and outputs * to a table using Latex.* The model is a piecewise growth model in a multilevel * framework (source: ALG's MADRCVisitGrowth031511.do). foreach y in bds {   runmplus unit_num y' vtimea vtimeb nonhosdel ,  ///      variable(GROUPING = nonhosdel(0=nah 1=ndl 2=del);  ///         within=vtimea vtimeb; cluster=unit_num; ) ///       analysis(estimator = MLR; iterations=1000; ///         type=twolevel random; processors = 2 ; ) ///   model( ///      %within% ///         s1 | y' ON vtimea ; ///         s2 | y' ON vtimeb; ///      %between% ///         [y']; [s1]; [s2]; s1 s2 WITH y' ; ///   MODEL NAH: ///      %within% ///      %between% ///         [y'] (i0); [s1] (s10); [s2] (s20); s1 s2 WITH y' ; ///   MODEL NDL: ///      %within% ///      %between% ///         [y'] (i1); [s1] (s11); [s2] (s21); s1 s2 WITH y' ; ///   MODEL DEL: ///      %within% ///      %between% ///         [y'] (i2); [s1] (s12); [s2] (s22); s1 s2 WITH y' ; ///   MODEL CONSTRAINT: new(ni10 ni20 ni21 n1s10 n1s20 n1s21 n2s10 n2s20 n2s21); ///      ni10 = i1-i0; n1s10 = s11-s10; n2s10 = s21-s20; ///      ni20 = i2-i0; n1s20 = s12-s10; n2s20 = s22-s20; ///                  ni21 = i2-i1; n1s21 = s12-s11; n2s21 = s22-s21; ///            ) output( tech4; !stdyx; !CINTERVAL;)} // ends foreach y * Pull estimates. The local plist' refers to the list of parameter names* that appear in MPLUS output. mat est = r(estimate)mat se = r(se)mat list estlocal plist: rowfullnames estdisplay "plist'"foreach x in plist' {      mat x' = est["x'",1]      local x': display %6.2f trunc(round(x'[1,1]*100,1))/100      mat x'se = se["x'",1]      local x'se: display %6.2f trunc(round(x'se[1,1]*100,1))/100      local lbx': display %6.2f trunc(round((x''-1.96*x'se')*100,1))/100      local ubx': display %6.2f trunc(round((x''+1.96*x'se')*100,1))/100} // ends foreach x * Make a table. cd c:\trash\capture erase table3.textexdoc init table3.tex   tex Table 3. Results of a multiple group latent growth model of BDS score since first MADRC visit using all follow-up (n=827) \\   tex \\   tex \\   tex \begin{tabular}{llccc} \hline   tex Group & Parameter & Estimate & SE & 95\%\ CI \\   tex \hline   tex (A) Not hospitalized \\   tex & Intercept & means_bds_nah' & means_bds_nahse' & (lbmeans_bds_nah', ubmeans_bds_nah') \\   tex & Slope before b' yrs & means_s1_nah' &means_s1_nahse' & (lbmeans_s1_nah', ubmeans_s1_nah') \\   tex & Slope after b' yrs & means_s2_nah' & means_s2_nahse' & (lbmeans_s2_nah', ubmeans_s2_nah') \\   tex (B) Hospitalized, no delirium \\      tex & Intercept & means_bds_ndl' & means_bds_ndlse' & (lbmeans_bds_ndl', ubmeans_bds_ndl') \\   tex & Slope before b' yrs & means_s1_ndl' & means_s1_ndlse' & (lbmeans_s1_ndl', ubmeans_s1_ndl') \\   tex & Slope after b' yrs & means_s2_ndl' & means_s2_ndlse' & (lbmeans_s2_ndl', ubmeans_s2_ndl') \\   tex (C) Hospitalized, delirium \\      tex & Intercept & means_bds_del' & means_bds_delse' & (lbmeans_bds_del', ubmeans_bds_del') \\   tex & Slope before b' yrs & means_s1_del' & means_s1_delse' & (lbmeans_s1_del', ubmeans_s1_del') \\   tex & Slope after b' yrs & means_s2_del' & means_s2_delse' & (lbmeans_s2_del', ubmeans_s2_del') \\   tex Group differences \\      tex & Intercept  \\   tex & B - A & new_ni10_del' & new_ni10_delse' & (lbnew_ni10_del', ubnew_ni10_del') \\   tex & C - A & new_ni20_del' & new_ni20_delse' & (lbnew_ni20_del', ubnew_ni20_del') \\   tex & C - B & new_ni21_del' & new_ni21_delse' & (lbnew_ni21_del', ubnew_ni21_del') \\   tex & Slope before b' yrs \\   tex & B - A & new_n1s10_del' & new_n1s10_delse' & (lbnew_n1s10_del', ubnew_n1s10_del') \\   tex & C - A & new_n1s20_del' & new_n1s20_delse' & (lbnew_n1s20_del', ubnew_n1s20_del') \\   tex & C - B & new_n1s21_del' & new_n1s21_delse' & (lbnew_n1s21_del', ubnew_n1s21_del') \\   tex & Slope after b' yrs \\   tex & B - A & new_n2s10_del' & new_n2s10_delse' & (lbnew_n2s10_del', ubnew_n2s10_del') \\   tex & C - A & new_n2s20_del' & new_n2s20_delse' & (lbnew_n2s20_del', ubnew_n2s20_del') \\   tex & C - B & new_n2s21_del' & new_n2s21_delse' & (lbnew_n2s21_del', ubnew_n2s21_del') \\   tex \hline   tex \end{tabular} texify2 table3, inashell