I'm trying to run a SEM model in Stata.
The N of dataset = 1,500.
The outcome (for the final model) is binary (ever_treated), and latent predictors consists of likert scale responses to several questions.
There are some missing values, both on outcome and predictors (not exceeding 2%).
At next step I'd like to estimate the final `gsem` model as follow:
In order to speed up the computations I tired Stata's solution of gradually increasing complexity of the path model for each single latent variable and storing estimates in matrices which are then reused (as per Stata manual recomendation). So for example 'Alternative' 'Established' latent variables are constructed (realtively fast) in this way:
In a similar vein I also constructed matrices a and c containing other latent variables. At next step I tried to run the following model and after two days of work it doesn't give any results whatsoever:
Of note, I tried running equivalent `sem` model (using `mlmv` method) and it estimates results without any issues (took few hours though).
Is there any mistake in the code causing that?
Or is the complexity of the model too much for Stata?
The N of dataset = 1,500.
The outcome (for the final model) is binary (ever_treated), and latent predictors consists of likert scale responses to several questions.
There are some missing values, both on outcome and predictors (not exceeding 2%).
At next step I'd like to estimate the final `gsem` model as follow:
Code:
gsem (Psychosocial -> fb2s fb2d fb2l fb2p fb2q, ologit) /// (Bio -> fb2n fb2c, ologit) (Narcotics -> fb2j fb2m, ologit) /// (Socialization -> fb2b fb2a fb2f fb2r, ologit) /// (Own -> fb2k fb2g fb2h, ologit) /// (Alternative -> new_fb5j new_fb8b new_fb8c new_fb8d new_fb8f, ologit) /// (Established -> new_fb5d new_fb5e new_fb5h new_fb8a new_b8e, ologit) /// (Non_prof -> new_fb5a new_fb5c new_fb5f new_fb5g, ologit) /// (Other_medical -> new_fb5b new_fb8g, ologit) /// (WSD -> fb15a-fb15g, ologit) /// (HelpA -> fb16 fb17 fb18 cat_fb12 new_fb19, ologit) /// (PublicS -> nfb21_1 nfb21_2 nfb21_3 nfb21_4 nfb21_8 nfb21_9, ologit) /// (PublicHelpA -> fb22_4 fb22_5 fb22_6 fb22_7 nfb22_9 fb22_10, ologit) /// (Established <- Psychosocial Socialization Bio Own Narcotics) /// (Alternative <- Psychosocial Socialization Bio Own Narcotics) /// (Non_prof <- Psychosocial Socialization Bio Own Narcotics) /// (Other_medical <- Psychosocial Socialization Bio Own Narcotics) /// (HelpA <- PublicHelpA PublicS Psychosocial Own Socialization Bio Narcotics) /// (WSD <- PublicHelpA PublicS Psychosocial Own Socialization Bio Narcotics), /// (ever_treated <- Established Alternative Non_prof Other_medical WSD HelpA, logit) /// latent(Psychosocial Own Socialization Bio Narcotics Alternative Established Non_prof Other_medical WSD HelpA PublicS PublicHelpA)
Code:
* Treatment recommendations * Alternative and Established (matrix b1) gsem (Alternative -> new_fb5j new_fb8b new_fb8c new_fb8d new_fb8f, ologit) /// (Established -> new_fb5d new_fb5e new_fb5h new_fb8a new_b8e, ologit), /// latent (Alternative Established) matrix b1 = e(b) * Other Medical and Non Professional (matrix b2) gsem (Non_prof -> new_fb5a new_fb5c new_fb5f new_fb5g, ologit) /// (Other_medical -> new_fb5b new_fb8g, ologit), /// latent (Non_prof Other_medical) matrix b2 = e(b) * ALL treatment recommendations gsem (Alternative -> new_fb5j new_fb8b new_fb8c new_fb8d new_fb8f, ologit) /// (Established -> new_fb5d new_fb5e new_fb5h new_fb8a new_b8e, ologit) /// (Non_prof -> new_fb5a new_fb5c new_fb5f new_fb5g, ologit) /// (Other_medical -> new_fb5b new_fb8g, ologit), /// latent (Alternative Established Non_prof Other_medical) from(b1 b2) est save "SEM_Treatment Recommendation", replace matrix b = e(b)
Code:
gsem (Psychosocial -> fb2s fb2d fb2l fb2p fb2q, ologit) (Bio -> fb2n fb2c, ologit) /// (Narcotics -> fb2j fb2m, ologit) /// (Socialization -> fb2b fb2a fb2f fb2r, ologit) /// (Own -> fb2k fb2g fb2h, ologit) /// (Alternative -> new_fb5j new_fb8b new_fb8c new_fb8d new_fb8f, ologit) /// (Established -> new_fb5d new_fb5e new_fb5h new_fb8a new_b8e, ologit) /// (Non_prof -> new_fb5a new_fb5c new_fb5f new_fb5g, ologit) /// (Other_medical -> new_fb5b new_fb8g, ologit) /// (WSD -> fb15a-fb15g, ologit) /// (HelpA -> fb16 fb17 fb18 cat_fb12 new_fb19, ologit) /// (PublicS -> nfb21_1 nfb21_2 nfb21_3 nfb21_4 nfb21_8 nfb21_9, ologit) /// (PublicHelpA -> fb22_4 fb22_5 fb22_6 fb22_7 nfb22_9 fb22_10, ologit) /// (Established <- Psychosocial Socialization Bio Own Narcotics) /// (Alternative <- Psychosocial Socialization Bio Own Narcotics) /// (Non_prof <- Psychosocial Socialization Bio Own Narcotics) /// (Other_medical <- Psychosocial Socialization Bio Own Narcotics) /// (HelpA <- PublicHelpA PublicS Psychosocial Own Socialization Bio Narcotics) /// (WSD <- PublicHelpA PublicS Psychosocial Own Socialization Bio Narcotics), /// latent(Psychosocial Bio Narcotics Socialization Own Alternative Established Non_prof Other_medical WSD HelpA PublicS PublicHelpA) /// from(a b c)
Is there any mistake in the code causing that?
Or is the complexity of the model too much for Stata?
Comment