Announcement

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

  • Twoway line of quantile regressions with multiple regressors

    Hi together,

    I try to replicate some parts of a paper from the Grotwh-at-Risk literature. However, the published code is only available in Matlab and I want to transform it to Stata now. I successfully performed the quantile regressions of "one quarter ahead GDP growth" on "current GDP growth" and some macro-finance variable called "NFCI". I am able to plot the linear univariate quantile regression lines ("one quarter ahead GDP growth" on "NFCI") for some chosen quantiles, but failing in plotting the linear lines for the multiple regression.

    Here are the (hopefully) necessary parts of my code:

    *** in-sample estimation (current GDP and NFCI)***

    foreach qq of numlist 5(5)95 {
    local n = `qq' * .01
    qreg yt_1 nfci yt, quantile(`n') vce(robust)
    predict yt_1_hat
    rename yt_1_hat yt_1_hat_q`qq'
    label var yt_1_hat_q`qq' q`qq'
    }

    twoway scatter yt_1 nfci || line yt_1_hat_nfci_q5 yt_1_hat_nfci_q50 yt_1_hat_nfci_q95 nfci, sort title("One quarter ahead: NFCI") ///
    xtitle("NFCI") ytitle("GDP growth 1 quarter ahead")
    The output is the following:
    Click image for larger version

Name:	multiple quantile regression.png
Views:	1
Size:	70.3 KB
ID:	1646132



    I guess, I need to manipulate something in the sorting. But I don't know further to be honest.


    Best,
    Mario
    Last edited by Mario Schimmels; 21 Jan 2022, 05:34.

  • #2
    Each quantile regression

    Code:
    qreg yt_1 nfci yt, quantile(`n') vce(robust)
    is fitting a plane in a 3-dimensional space, so sorting alone won't reduce that set of predictions to a line. Perhaps you want to see something else

    Comment


    • #3
      Dear Nick,

      you were absolutely right! The relation I was looking for cannot be displayed in a 2D space. Thanks!

      Comment


      • #4
        Hi Mario Schimmels,
        I'm interested in GaR literature as well, would you please share the link for the Matlab code, along with the paper, for this particular exercise?

        Best,
        Sarah

        Comment

        Working...
        X