Announcement

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

  • deltacovar A.Brunnermeier

    Goodmorning. I'm doing an analysis on a sample of 59 banks (DATASET UNBALANCED).
    I'm following the paper based on the costruction of deltaCOVAR written by A.Brunnermeier.
    I just know the commands to calculate Var and Covar in order to estimate deltaCOVAR finally.

    The commands are:

    qreg Xi IBOVESPAReturnlag IBOVESPAVolatilitylag LiquiditySpreadlag ChangeCreditSpreadlag ChangeYieldSlopelag ChangeTbilllag ,quantile(.05)
    predict Xi_predict95 ,xb

    gen Xi_predict95lag = Xi_predict95[_n-1]


    qreg XSYST Xi_predict95 IBOVESPAReturnlag IBOVESPAVolatilitylag LiquiditySpreadlag ChangeCreditSpreadlag ChangeYieldSlopelag ChangeTbilllag,quantile(.05)
    predict XSYST_predict95,xb

    qreg Xi IBOVESPAReturnlag IBOVESPAVolatilitylag LiquiditySpreadlag ChangeCreditSpreadlag ChangeYieldSlopelag ChangeTbilllag,quantile(.50)
    predict Xi_predict50,xb

    gen Xi_predict50lag = Xi_predict50[_n-1]

    qreg XSYST Xi_predict50 IBOVESPAReturnlag IBOVESPAVolatilitylag LiquiditySpreadlag ChangeCreditSpreadlag ChangeYieldSlopelag ChangeTbilllag,quantile(.50)
    predict XSYST_predict9550,xb

    gen deltacovar = XSYST_predict95 - XSYST_predict9550

    The problem is that i obtained the same value of Xi_predict95 for each banks in spite of each banks have different Xi. Probably i must use the command "forvalues...." but i don't have results probably because i must distinguish id banks and time variabile because it's UNBALANCED.

    forvalues i = 1/59 {
    qreg Xi IBOVESPAReturnlag IBOVESPAVolatilitylag LiquiditySpreadlag ChangeCreditSpreadlag ChangeYieldSlopelag ChangeTbilllag if IDBanks ==`i', quantile(.05)
    predict var5_`i' if IDBaks==`i', xb `i'
    replace var5_`i'=0 if var5_`i'==.
    replace var5=var5+var5_`i'
    drop var5_`i'
    }

    Someone, can help me with the right commands?
    Thank you so much,

  • #2
    Hi. I have the same problem. I'm using a panel data unbalanced for 59 banks.
    My dataset is based on: ID= ID BANKS q=quarterly obi=observations Year =year

    ID q obi. Year
    1 1 1 2002
    1 2 2 2002
    1 3 3 2002
    1 .. .. 2002
    1. .. .. 2003
    1 ... .. ....
    1..... .... ......
    1.... .... ......
    1.... ..... .......
    1 56 56 2015
    2 1 57 2002
    2 2 58 2002
    2 3 59 2002
    2 4 60 2002
    ... ..... .... ...

    I must estimate Value at risk and Covar through a quantile regressione, but i don't know how to create the command forvalues in this case.
    Someone can i help me please=

    Comment


    • #3
      Robert Picard Could you help me please? ( i have read some of your answers about this argument on other posts)

      Comment


      • #4
        I did indeed post a solution to a similar request yesterday so I guess this means that you cannot figure out how to adapt my suggestion to your predicament. I skipped over your post because I'm not in finance and I could not make heads or tails of it. I'm reluctant to give advice to people who haven't quite figured out what they are trying to do. With that caveat, here's the same solution adapted to your loop problem:
        Code:
        * perform a regression per company
        program my_qreg
          qreg Xi IBOVESPAReturnlag IBOVESPAVolatilitylag LiquiditySpreadlag ChangeCreditSpreadlag ChangeYieldSlopelag ChangeTbilllag, quantile(0.05)
          predict p, xb
        end
        runby my_qreg, by(IDBanks)

        Comment


        • #5


          ChatGPT

          Hello everyone, I am a new user of Stata. I am writing my thesis. I need to calculate the Delta CoVaR as described by Adrian and Brunnermeier, and the procedures are the same:
          • calculate var5 * for values i = 1/35 { qreg x ftse_vol liq_sp tbill_ch y_slope ftse_ret dcredit_sp if bank_id_adj==i', quantile(.05) predict var5_i' if bank_id_adj==i', xb replace var5_i'=0 if var5_i'==. replace var5=var5+var5_i' drop var5_`i' } gen lag_var5 = var5[_n-1]
          • calculate var50 * for values i = 1/35 { qreg x ftse_vol liq_sp tbill_ch y_slope ftse_ret dcredit_sp if bank_id_adj==i', quantile(.50) predict var50_i' if bank_id_adj==i', xb replace var50_i'=0 if var50_i'==. replace var50=var50+var50_i' drop var50_`i' } gen lag_var50 = var50[_n-1]
          • calculate acovar5(i) * for values i = 1/35 { qreg xsys var5 ftse_vol liq_sp tbill_ch y_slope ftse_ret dcredit_sp if bank_id_adj==i', quantile(.01) predict acovar5_i' if bank_id_adj==i', xb replace acovar5_i'=0 if acovar5_i'==. replace acovar5=acovar5+acovar5_i' drop acovar5_`i'
          }
          • calculate acovar50(i) * for values i = 1/35 { qreg xsys var50 ftse_vol liq_sp tbill_ch y_slope ftse_ret dcredit_sp if bank_id_adj==i', quantile(.50) predict acovar50_i' if bank_id_adj==i', xb replace acovar50_i'=0 if acovar50_i'==. replace acovar50=acovar50+acovar50_i' drop acovar50_`i' }
          • calculate dacovar(i) * gen dacovar=acovar5-acovar50
          I am working with a panel of 35 banks for 32 quarterly observations each for every variable. My panel is unbalanced. When I run the q regression for the VAR at the 5th quantile it gives me a VCE error, how can I obtain the observations for each bank?

          Comment


          • #6
            Robert Picard could you help me please?

            Comment


            • #7

              Hello everyone, I am a new user of Stata. I am writing my thesis. I need to calculate the Delta CoVaR as described by Adrian and Brunnermeier, and the procedures are the same:
              • calculate var5 * for values i = 1/35 { qreg x ftse_vol liq_sp tbill_ch y_slope ftse_ret dcredit_sp if bank_id_adj==i', quantile(.05) predict var5_i' if bank_id_adj==i', xb replace var5_i'=0 if var5_i'==. replace var5=var5+var5_i' drop var5_`i' } gen lag_var5 = var5[_n-1]
              • calculate var50 * for values i = 1/35 { qreg x ftse_vol liq_sp tbill_ch y_slope ftse_ret dcredit_sp if bank_id_adj==i', quantile(.50) predict var50_i' if bank_id_adj==i', xb replace var50_i'=0 if var50_i'==. replace var50=var50+var50_i' drop var50_`i' } gen lag_var50 = var50[_n-1]
              • calculate acovar5(i) * for values i = 1/35 { qreg xsys var5 ftse_vol liq_sp tbill_ch y_slope ftse_ret dcredit_sp if bank_id_adj==i', quantile(.01) predict acovar5_i' if bank_id_adj==i', xb replace acovar5_i'=0 if acovar5_i'==. replace acovar5=acovar5+acovar5_i' drop acovar5_`i'
              }
              • calculate acovar50(i) * for values i = 1/35 { qreg xsys var50 ftse_vol liq_sp tbill_ch y_slope ftse_ret dcredit_sp if bank_id_adj==i', quantile(.50) predict acovar50_i' if bank_id_adj==i', xb replace acovar50_i'=0 if acovar50_i'==. replace acovar50=acovar50+acovar50_i' drop acovar50_`i' }
              • calculate dacovar(i) * gen dacovar=acovar5-acovar50
              I am working with a panel of 35 banks for 32 quarterly observations each for every variable. My panel is unbalanced. When I run the q regression for the VAR at the 5th quantile it gives me a VCE error, how can I obtain the observations for each bank?
              [/QUOTE]

              Comment

              Working...
              X