Dear Statlist

I am trying to condut the serial mediation analysis using a large stock market dataset with number of observations as 349,428. The number of stocks are around 800.

I learned from the web that sem and gsem in stata can be used for this purpose.

I picked gsem instead of sem as my model needs to control firm fixed effect and given the large number firms in the dataset, using factor variables would be handy. gsem allow me to use factor variables.

However, as my dataset is too big, I cannot run the model. The following is my code:

gsem( spread <- financeratio shortratio i.stkcd) (leadeffect <- spread financeratio shortratio i.stkcd), nocapslatent

spread is my mediation variable, financeratio and shortratio are my two IV, leadeffect is my DV.

The error message I got is the following:

J(): 3900 unable to allocate real <tmp>[348907,1713]
_gsem_eval_iid__wrk(): - function returned error
_gsem_eval_iid(): - function returned error
mopt__calluser_v(): - function returned error
opt__eval_nr_v2(): - 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
_moptimize(): - function returned error
Mopt_maxmin(): - function returned error
<istmt>: - function returned error
r(3900);

When I check r(3900), I was told it means "out of memory". I guess it is because the i.stkcd has too many variables (more than 800 firms). So my question is, can gsem allow fixed effect? can it be used to run a large dataset?