Announcement

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

  • #31
    Dear Clyde Schechter

    Could you also let me know how to introduce the syntax for finding the error term of the regression as well in the below for each loop:

    program define one_id
    qreg Y X1 X2 X3 , q(0.99)
    foreach v of varlist X1 X2 X3{
    gen coeff_`v' = _b[`v']
    gen se_`v' = _se[`v']
    gen t_`v' = coeff_`v'/se_`v'
    gen p_`v' = 2*t(e(df_r), -abs( t_`v'))
    }
    gen constant_term = _b[_cons]
    gen se_constant = _se[_cons]
    predict V
    exit
    end
    runby one_id, by(FI) status

    Comment


    • #32
      Just add -predict resid, resid- immediately before the -exit- command and you will have a new variable, called resid, which contains the residual (error term).

      Comment


      • #33
        Thank Clyde Schechter

        Could you please reply my other query titled "GARCH regressions for panels using foreach"

        I have already tagged you there.

        Comment


        • #34
          I did not reply there because I do not know anything about it. Sorry.

          Comment


          • #35
            Dear Clyde Schechter

            I have thought of doing this the other way but would like to know some simpler things foreach loop this time.

            I have 360 firms with 20 years of daily data(2000-2019). I want to do some calculation for each of the panels in my data.

            1. I have to calculate variance for only first day of data in each firm(3rd Jan 2000), as the variance of the returns array (where returns should be the first 500 observations in the data, starting from 3rd Jan 2000 till 15th June 2002 (approx 500days).

            2. Then I have to use a formula for all the other days in each panel *4th Jan 2000 to end 2019); formula is
            w+a*((L.R-q*SQRT(L.variance)^2)+b*L.Variance
            where L.R is lagged returns and w,a,c and b are the estimates. L.variance is the lagged variance.

            3. lastly I have to calculate a rolling variable (VaR) as the -NORMSINV(0.01)*SQRT(variance) , which should start from the 501th observation in the data till the end.

            Please let me know If you want to know more about this.

            Regards

            Comment


            • #36
              This is off the topic of the thread. And it is not advisable to address a question to any specific person. These threads are not dialogs between questioners and responders, though it often feels as if they are. Other people come to the Forum with questions and search for answers among the existing threads. The searches are based on the titles of the threads: off-topic material will be missed by people who are searching for it, and will waste the time of those who really wanted to read about the topic. Targeting a single responder is ill-advised as that person may have nothing useful to say about it, or may not even be visiting the Forum during the time frame you would hope to receive a response.

              So please repost this question as a New Topic in the General Forum and do not address it specifically to anybody.

              When you do that, be sure to use -dataex- to show some example data.

              Comment

              Working...
              X