Dear all,

I am trying to estimate Diagonal VECH GARCH(1,1) model for a panel of 600 firms (ID) and then predict the variance for every case, however my code does not work. Can you help me with the code please:

Code:
gen variance = .
foreach x of var ID {
   mgarch dvech (var1 = var2 l.var2 l.var1) if ID==`x' , arch(1) garch(1) nolog
   predict v_var1_var1 if ID==`x' , variance
   replace variance = v_var1_var1 if ID == `x'
   drop v_var1_var1 }

sample may not include multiple panels
r(459);
Any help is highly appreciated. Thank you advance.