Announcement

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

  • How to regress many variables at the same time with qreg + list them

    Hey guys, I'm currently doing a quantil regression with the command qreg variable X, q(1).
    My data are many banks = variables with their development of price history per day which looks like this (this is a small extract)

    My point is, i have 81 variables (lets call them X1, X2, ..., X81) and i want to regress them all in one command (like: qreg AAREALBANK, q(1)) and not type the command for every single variable.

    1) how can I do this ? I looked trough many options like loops but its kinda hard for me to programm it.


    2) Afterwarts I want to create a new variable (lets call it VaR1) which is a list of the results from all the 1% Quantil regressions I did. Is this possible ?
    The results from qreg looks like this and the red colored value (the rest is unimortant) is the value from all 81 regressions i want to list in a new variable.

    I uploaded my stata stata if anyone wants to check further
    http://www59.zippyshare.com/v/c48c3NhH/file.html.


    Basically I know i could just create everything manuel with excel but I'm searching for a stata solution code.

    With kindly regards, Lisa


    Last edited by Lisa Meier; 04 Dec 2017, 04:27.

  • #2
    Lisa:
    please, read the FAQ about:attachments; -dataex-; CODE delimiters. Thanks.
    Besides, please note that most listers (me, too) shy away from downloading any kind of stuff from unknown sources due to the risk of active contents.
    That said: are you sure that regressing your <depvar> on each predictor separalely makes sense?
    By the way, a regression with 81 predictors makes little methodological sense either.
    As per https://projecteuclid.org/euclid.aos/1176350710 with 81 predictors and 1 constant you should have a number of observations 8-10 times >(82^2)=6724 to make your -qreg- acceptable.
    What is your sample size?
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      I have 81 Variables with each 1872 observations = 150.000 observations at all.

      My method is fine, I'm preparing a Value-at-Risk analysis so I need to do a quantil regression on each variable without an independant variable first.
      From the individual quantil I can do my next steps (analyse the systemic risk).

      Comment


      • #4
        Lisa:
        thanks for providing further clarifications.
        Perhaps someone skilled in quantitative finance will chime in and help you out as you need.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Yes thanks anyway.

          I'm not discussing about my method so I think there is no deeper knowledge needed, I just need some advises how to program my given questions in stata.
          --> do something like a loop on qreg to do a quantil regression on many variables (= qreg variable X, q(1)...) and put results in a new variable.
          Last edited by Lisa Meier; 04 Dec 2017, 05:04.

          Comment


          • #6
            Your question could be much clearer. Without knowing your variable labels etc., it is hard to know how to help you. I'm not sure if you want 81 separate regressions or one regression with 81 rhs variables. If the former and your x variables are labelled 1 to 81 then
            g b=.
            local j=1
            forvalues i=1/81{
            reg y x`i'
            replace b=_b[x`i'] in `j'/`j'
            local j=`j' + 1
            }
            would do most of what you want. I'm not sure exactly how to refer to the rhs variable. For example, for reg, you can easily find out by issuing the estimation statement after you do the estimate - reg,coefl.

            Comment


            • #7
              Originally posted by Phil Bromiley View Post
              Your question could be much clearer. Without knowing your variable labels etc., it is hard to know how to help you. I'm not sure if you want 81 separate regressions or one regression with 81 rhs variables. If the former and your x variables are labelled 1 to 81 then
              g b=.
              local j=1
              forvalues i=1/81{
              reg y x`i'
              replace b=_b[x`i'] in `j'/`j'
              local j=`j' + 1
              }
              would do most of what you want. I'm not sure exactly how to refer to the rhs variable. For example, for reg, you can easily find out by issuing the estimation statement after you do the estimate - reg,coefl.
              Hey Phil, thx for your adice. I want 81 seperate quantil regressions organized in one loop instead of doing 81 single regressions. So you got it right.
              Basically i have very easy and clear data, its just 81 different variables (european banks) with each 1872 observations of their share price.

              I already checked the forvalues or foreach functions but didnt understand how to use them exactly and I will check your advise.

              Comment

              Working...
              X