Hello,
I am conducting a latent profile analysis and trying to compare models with 2 through 5 profile solutions. I am constructing a table of some post-estimation statistics, one of which is a scalar for entropy ("E") that I have calculated manually using code from another StataList post. I have been able to get the standard post-estimation stats (log likelihood, degrees of freedom, AIC, and BIC) into a collection and displayed in a table without any issue, but I cannot figure out how to get the scalars into the collection or how to do so in such a way that I can put them into the resulting table properly. The code below runs, but I need the scalars E2 through E6 in a column corresponding to rows designated by c2pinv through c6pinv.
I appreciate any suggestions.
-Matt
I am conducting a latent profile analysis and trying to compare models with 2 through 5 profile solutions. I am constructing a table of some post-estimation statistics, one of which is a scalar for entropy ("E") that I have calculated manually using code from another StataList post. I have been able to get the standard post-estimation stats (log likelihood, degrees of freedom, AIC, and BIC) into a collection and displayed in a table without any issue, but I cannot figure out how to get the scalars into the collection or how to do so in such a way that I can put them into the resulting table properly. The code below runs, but I need the scalars E2 through E6 in a column corresponding to rows designated by c2pinv through c6pinv.
I appreciate any suggestions.
-Matt
Code:
collect clear forvalues i=2/6 { quietly gsem ($vars1 <- _cons)(C<- $vars2), family(gaussian) link(identity) lclass(C `i') estimates store c`i'pinv quietly predict classpost*, classposteriorpr gen sum_p_lnp = 0 forvalues k = 1/`i' { replace sum_p_lnp = sum_p_lnp + classpost`k'*ln(classpost`k') } summ sum_p_lnp, meanonly scalar E`i' = 1+`r(sum)'/(e(N)*ln(2)) di E`i' drop classpost* sum_p_lnp } quietly collect: estimates stats c2pinv c3pinv c4pinv c5pinv c6pinv *Table collect layout (rowname[c2pinv] rowname[c3pinv] rowname[c4pinv] rowname[c5pinv] rowname[c6pinv]) (colname[df] colname[ll] colname[BIC] colname[AIC]) (), name(default) collect preview