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:
The output is the following:

I guess, I need to manipulate something in the sorting. But I don't know further to be honest.
Best,
Mario
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")
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")
I guess, I need to manipulate something in the sorting. But I don't know further to be honest.
Best,
Mario

Comment