Hello Statalist expert,
I'm trying to plot 2 densities in one graph, to see how the distribution is shifted through time; or the evolution of the distribution
my code is as follows:
However, it keeps giving me a rotated density (see below), and I really need someone to tell me how to fix it:

Thanks in advance
Sarah
I'm trying to plot 2 densities in one graph, to see how the distribution is shifted through time; or the evolution of the distribution
my code is as follows:
Code:
sqreg zex_pi zpi zreer zgap zgsci zpi_lte, quantile(.1 .2 .3 .4 .5 .6 .7 .8 .9) reps(100) //ssc install ftools qregplot zpi zreer zgap zgsci zpi_lte, ols ///////fitting in the skew-t distribution //identify structural breaks regress ex_pi core reer_gap gdp_gap gsci pi_lte, vce(robust) estat sbsingle ///Estimated break date: 2006q3 gen shift=1 if Date>tq(2006q3) replace shift=0 if Date<=tq(2006q3) skewtreg ex_pi core reer_gap gdp_gap gsci pi_lte if shift ==1,difficult predict resid1, residuals predict fitted1 if e(sample) kdensity resid1, normal kdensity fitted1, kernel( gaussian) gen(x1 gaussian1) skewtreg ex_pi core reer_gap gdp_gap gsci pi_lte if shift ==0, difficult predict resid0, residuals predict fitted0 if e(sample) kdensity resid0, normal kdensity fitted0, kernel( gaussian) gen(x0 gaussian0) //entire sample skewtreg ex_pi core reer_gap gdp_gap gsci pi_lte, difficult predict resid2, residuals predict fitted2 if e(sample) kdensity resid2, normal kdensity fitted2, kernel(gaussian) gen(x2 gaussian2) twoway (line (x0 gaussian0), lcolor(grey)) (line (x1 gaussian1), lcolor(cranberry)), legend(order(1 "Core-2Q, before 2006q3" 2 "Core-2Q, after 2006q3"))
Thanks in advance
Sarah
Comment