Dear Stata users,
I'm trying to run a SEM model in Stata 18 for a panel data set (that you can download here). I would like to use this information to understand the indirect and direct effects in this model, by using M1 and M2 variables as mediation variables, the IV, CV1, CV2, and CV3 as independent variables, and the "DV" as dependent variable. Since it is a panel data, I would like to account for unit (id_dum) and time (year_dum) fixed effects. I have tried so many things without success.
My 1st try was with the sem command, which works perfect. But it doesn't include the unit and time fixed effects:
Therefore, my 2nd try was including unit and time fixed effects. But I got an error message related to the fitting model:
My 3rd try was using the xtdpdml command, but I got an error saying there is an invalid name:
Does anyone know how to properly code a SEM model (that considers a mediation variable) with unit and time fixed effects in Stata? Any help is appreciated!
I'm trying to run a SEM model in Stata 18 for a panel data set (that you can download here). I would like to use this information to understand the indirect and direct effects in this model, by using M1 and M2 variables as mediation variables, the IV, CV1, CV2, and CV3 as independent variables, and the "DV" as dependent variable. Since it is a panel data, I would like to account for unit (id_dum) and time (year_dum) fixed effects. I have tried so many things without success.
Code:
use "...\PanelData.dta", clear xtset id timevar, delta(1) qui tabulate id, generate(id_dum) qui tabulate timevar, generate(year_dum)
Code:
sem (DV <- M1 M2 IV CV*, ) (M1 <- IV CV*, ) (M2 <- IV CV*, ), vce(robust) nocapslatent
Code:
sem (DV <- MV1 MV2 IV CV* id_dum* year_dum*, ) /// (MV1 <- IV CV* id_dum* year_dum*, ) /// (MV2 <- IV CV* id_dum* year_dum*, ), vce(robust) nocapslatent Fitting target model: __sem_d2L_dth2(): 3900 unable to allocate real <tmp>[111155,111155] _sem_eval_ml_d2_g(): - function returned error __sem_d2L_dth2(): 3900 out of memory _sem_eval_ml_d2_g(): - function returned error _sem_eval_ml_d2(): - function returned error opt__calluser1_d(): - function returned error opt__eval_nr_d2(): - function returned error opt__eval(): - function returned error opt__looputil_iter0_common(): - function returned error opt__looputil_iter0_nr(): - function returned error opt__loop_nr(): - function returned error opt__loop(): - function returned error _optimize(): - function returned error _sem_fit(): - function returned error st_sem_fit(): - function returned error <istmt>: - function returned error
Code:
xtdpdml (MV1 <- IV CV* id_dum* year_dum*) /// (MV2 <- IV CV* id_dum* year_dum*) /// (DV <- MV1 MV2 IV CV* id_dum* year_dum*), /// lags(0) iv(IV CV1 CV2 CV3) fe twostep robust < invalid name r(198);
Comment