I am trying to build my Mata skill set and would appreciate help with what I expect is a relatively simple programming task.
In the following toy example (using data from the Stata 15 sem.pdf manual), I would like to learn how to combine STEPS 3-5 in my Mata code into a single step, if that is possible. I've used verbose matrix names in my example code just for clarity.
I'm not interested in the substance of this particular example and know that I can obtain the item response probabilities matrix directly with the postestimation command -estat lcmean, post-. I am only using this example to illustrate the programming task I'm trying to learn how to perform with Mata.
Thanks very much for any advice you may offer.
Red Owl
(yes, my real name)
Stata/IC 15 with Windows 10
In the following toy example (using data from the Stata 15 sem.pdf manual), I would like to learn how to combine STEPS 3-5 in my Mata code into a single step, if that is possible. I've used verbose matrix names in my example code just for clarity.
Code:
use http://www.stata-press.com/data/r15/gsem_lca1 gsem (accident play insurance stock <- ), logit lclass(C 2) mat B = e(b)' mata mataB = st_matrix("B") /* STEP1: Import logistic coefficients matrix from Stata */ mataB /* STEP2: Display logistic coefficients matrix in Mata */ mataNUMERATOR = exp(mataB[1...,1..1]) /* STEP3: Create Odds matrix */ mataDENOMINATOR = exp(mataB[1...,1..1]) :+ 1 /* STEP4: Create (1 + Odds) matrix */ mataPROBS = mataNUMERATOR :/ mataDENOMINATOR /* STEP5: Create probabilities matrix as Odds/(1+Odds) */ mataPROBS /* STEP6: Display item response probabilities matrix */ st_matrix("PROBS", mataPROBS) /* STEP7: Export item response probabilities matrix to Stata */ end
Thanks very much for any advice you may offer.
Red Owl
(yes, my real name)
Stata/IC 15 with Windows 10
Comment