Dear Stata Users

I'm currently testing a mediation model with a panel data structure using xtreg in Stata.
This is because it appears the gsem command is incompatible with a panel data structure.

The logic of the mediation model is based on Baron & Kenny (1986), where

1. Explanatory variable is significantly associated with the mediator
2. Mediator is significantly associated with DV
3. When explanatory variable and mediator are included together, the influence of the explanatory V is reduced.

Thus, my code looks something like:
Code:
xtreg M IV $key_control  i.year 
xtreg DV M $key_control i.year 
xtreg DV IV M $key_control i.year
Afterwards, I'm trying to calculate the
1. indirect effect of the explanatory variable mediated by the mediator
2. direct effects of both the explanatory variable and the mediator on the DV
3. the total effects of the explanatory variable and the mediator on the DV

with the boot estimates, standard errors, and the confidence intervals.

Doing this was not challenging with gsem, but I'm currently stuck on how I should proceed when using the xtreg command.
I think there should be a way to simultaneously run the models, but I am not sure.

There was a similar thread that I attach, but the contents appeared inconclusive
https://www.statalist.org/forums/for...sing-bootstrap

If you have any advice on the matter, I would greatly appreciate it.
Thank you.