Page 1 of 1

multiple density plot on the same graph

Posted: Wed Sep 13, 2023 7:31 am
by ndzama
Hello!

In Eviews, how do I create multiple density plots on the same graph?

See attachment.

I would like to create a similar graph, where each plot shows the density distribution for each forecast horizon (e.g h=1; h=2; h=3; h=4)

so far I have attempted this code, but it fails to give multiple plots on the same graph:
For !c = 1 to 5
%c = table_countries(!c,1)

if %CA_forecast_model1 = "AR" then
solve model_CA_AR_{%c}
genr CA_{%c}_0_AR = CA_{%c}_0 'Current Account Forecast
series ca_pdf_{%c}=@dnorm(CA_{%c}_0_AR)
'show ca_pdf_{%c}.line
group pdf_ca_{%c} CA_{%c}_0_AR ca_pdf_{%c}
'show pdf_ca_{%c}.scat
'show pdf_ca_{%c}.xyline
'group pdf_ca_{%c}.xyline

'--------------KERNEL DENSITY , assmuing Normal (Gaussian)---------------'
'ca_{%c}_0_ar.sheet
'CA_{%c}_0_AR.distdata(dtype=kernel, k=n) ca_pdf_{%c} ' How do I create multiple kernels for different forecast horizons? Maybe use a For Loop?
' show ca_pdf_{%c}.xyline
'show ca_pdf_{%c}.distplot kernel(k=n, lgnd=detail).xyline

'--------ATTEMPTING TO PLOT THE KERNELS ON THE SAME GRAPH--------
pdf_ca_{%c}.displot(s) kernel(k=u, x)
endif
Next '!c


Kind Regards,
N

Re: multiple density plot on the same graph

Posted: Wed Sep 13, 2023 8:54 am
by EViews Gareth
I don't follow the specifics, but it seems you are saving the dist plot data into the workfile. You just need to do that for all the horizons and then graph them together?