Hello Statalisters,

My data is daily panel data that consists of 379 firms:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int Timestamp long Company float(id resid)
18535 1 1  -.5671907
18536 1 1  -.6045171
18539 1 1  -.6121998
18540 1 1  -.6303514
18541 1 1   -.669826
18542 1 1   -.702639
18543 1 1   -.719861
18546 1 1  -.6933156
18547 1 1   -.731853
18548 1 1  -.7365888
18549 1 1  -.7747283
18550 1 1  -.7631773
18553 1 1  -.7770729
18554 1 1  -.8012897
18555 1 1  -.8964902
18556 1 1   -.913472
18557 1 1  -.9855964
18560 1 1   -.999239
18561 1 1  -.9881337
18562 1 1 -1.0019863
18563 1 1 -1.0206912
18564 1 1 -1.0217553
18567 1 1 -1.0474454
18568 1 1  -1.045138
18569 1 1 -1.0861173
18570 1 1 -1.0813621
18571 1 1 -1.1092516
18574 1 1 -1.0936003
18575 1 1   -1.11229
18576 1 1 -1.1059849
18577 1 1 -1.1025311
18578 1 1 -1.1074014
18581 1 1 -1.1109506
18582 1 1 -1.1378505
18583 1 1 -1.0972226
18584 1 1  -1.081413
18585 1 1 -1.0957986
18588 1 1 -1.2032365
18589 1 1 -1.1156594
18590 1 1 -1.1093435
18591 1 1  -1.119484
18592 1 1 -1.1405734
18595 1 1 -1.1548105
18596 1 1 -1.1471893
18597 1 1 -1.1450335
18598 1 1 -1.2197285
18599 1 1 -1.2260885
18602 1 1  -1.254092
18603 1 1 -1.2256622
18604 1 1 -1.2525495
18605 1 1  -1.260203
18606 1 1 -1.2446553
18609 1 1 -1.2434903
18610 1 1 -1.2611834
18611 1 1 -1.2991477
18612 1 1 -1.3018358
18613 1 1  -1.300265
18616 1 1 -1.2987148
18617 1 1  -1.289396
18618 1 1 -1.3019747
18619 1 1 -1.3019783
18623 1 1 -1.3298627
18624 1 1 -1.3500524
18625 1 1 -1.3450558
18626 1 1 -1.3278207
18630 1 1 -1.3412284
18631 1 1 -1.3589562
18632 1 1 -1.3617107
18634 1 1 -1.4429946
18637 1 1  -1.425543
18638 1 1  -1.430764
18639 1 1 -1.4498658
18640 1 1  -1.439363
18641 1 1  -1.480617
18644 1 1  -1.472839
18645 1 1  -1.471289
18646 1 1  -1.559699
18647 1 1   -1.55628
18648 1 1 -1.5369538
18651 1 1 -1.5414712
18652 1 1 -1.5362016
18653 1 1 -1.5512855
18654 1 1  -1.596582
18655 1 1 -1.6015798
18658 1 1 -1.6236287
18659 1 1   -1.62002
18660 1 1  -1.633923
18661 1 1 -1.6823018
18662 1 1 -1.7491394
18665 1 1  -1.698604
18666 1 1 -1.7063757
18667 1 1 -1.6978794
18668 1 1 -1.7265545
18669 1 1  -1.708142
18672 1 1 -1.7848433
18673 1 1 -1.7568833
18674 1 1  -1.757743
18675 1 1 -1.7850047
18676 1 1 -1.7637664
18679 1 1  -1.782558
end
format %tdnn/dd/CCYY Timestamp
label values Company Company
label def Company 1 "AAK.ST", modify
id is basically a firm id and I have 379 ids one for each of my 379 firms. resid is my main variable.
I am trying to run an EGARCH model for each company separately and save the residuals before running the next EGARCH model for id ==2 and so on, using resid as my dependent variable with no independent variables. So this is my model:

Code:
arch resid , earch(1/1) egarch(1/1)
It is possible to run a panel EGARCH model as follows but the problem is saving each regression's residuals before running the next regaression:

Code:
by id: arch resid , earch(1/1) egarch(1/1)
I thought of Mr. Cox's rangerun code and did something like:

Code:
program define EGARCH
    arch resid , earch(1/1) egarch(1/1)
    predict IV, residuals
    exit
end
rangerun EGARCH, interval( Timestamp 0 0) by(id) verbose
but stata wanted a time variable although I already declared my data.

Code:
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname ...
time variable not set, use tsset varname .
Thus, I did this

Code:
program define EGARCH
    xtset id Timestamp, daily
    arch resid , earch(1/1) egarch(1/1)
    predict IV, residuals
    exit
end
rangerun EGARCH, interval( Timestamp 0 0) by(id) verbose
and I got

Code:
insufficient observations
       panel variable:  id (strongly balanced)
        time variable:  Timestamp, 16oct2013 to 16oct2013
                delta:  1 day
insufficient observations
       panel variable:  id (strongly balanced)
        time variable:  Timestamp, 17oct2013 to 17oct2013
                delta:  1 day
insufficient observations
       panel variable:  id (strongly balanced)
        time variable:  Timestamp, 18oct2013 to 18oct2013
                delta:  1 day
insufficient observations
       panel variable:  id (strongly balanced)
        time variable:  Timestamp, 21oct2013 to 21oct2013
                delta:  1 day
insufficient observations
       panel variable:  id (strongly balanced)
        time variable:  Timestamp, 22oct2013 to 22oct2013
                delta:  1 day
insufficient observations
       panel variable:  id (strongly balanced)
        time variable:  Timestamp, 23oct2013 to 23oct2013
                delta:  1 day
insufficient observations
       panel variable:  id (strongly balanced)
        time variable:  Timestamp, 24oct2013 to 24oct2013
                delta:  1 day
insufficient observations
       panel variable:  id (strongly balanced)
        time variable:  Timestamp, 25oct2013 to 25oct2013
                delta:  1 day
insufficient observations
I know that I have sufficient observations to run the EGARCH model because I have already run the EARCH model without saving the residuals and had no issues there. I must be doing something wrong. I might not have sat up the right interval in the rangerun with 0 0. My understanding is that 0 0 takes the full period of id == 1 :
Code:
rangerun EGARCH, interval( Timestamp 0 0) by(id) verbose
I was also reading about Mr.Cox's rangestat code but I was not able to incorporate the arch/garch models in rangestat.

I appreciated any help/tip in solving my issue.