Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • "predict H*, variance" after "mgarch dcc" with by

    Happy holidays!
    I am looking for a workaround for predict H*, variance after mgarch dcc with by prefix. The issue is that mgarch dcc allows by prefix, but predict H*, variance post-estimation command does not. Is there a way to get an equivalent result? Essentially, I'm looking for by ID : predict H* , variance after running by ID: mgarch dcc (Y X = , noconstant), arch(1) garch(1).
    Thank you very much.

  • #2
    Assuming that ID is a numerical variable:

    Code:
    levelsof ID, local(IDs)
    foreach ID of local IDs{
        mgarch dcc (Y X = , noconstant) if ID==`ID', arch(1) garch(1)
        predict H`ID' if ID==`ID', variance
    }

    If string, add the double quotes or encode and then loop over the encoded variable.
    Last edited by Andrew Musau; 29 Dec 2022, 23:56.

    Comment


    • #3
      Thank you. The code above gives predictions for variance of Y. What I need is variance of Y, variance of X and covariance between Y and X. Normally, predict H* , variance creates 3 variables (assuming there is only Y and X to start with) corresponding to the two variances and one covariance. Is there a minor modification to the code above that would create the other variables I'm looking for?

      Comment


      • #4
        Just add the asterisk to the predict command.

        Code:
        levelsof ID, local(IDs)
        foreach ID of local IDs{
            mgarch dcc (Y X = , noconstant) if ID==`ID', arch(1) garch(1)
            predict H`ID'* if ID==`ID', variance
        }

        Comment

        Working...
        X