multiple density plot on the same graph

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

ndzama
Posts: 15
Joined: Tue Aug 10, 2021 8:33 am

multiple density plot on the same graph

Postby ndzama » Wed Sep 13, 2023 7:31 am

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
Attachments
Multiple kernel density plot.docx
(46.92 KiB) Downloaded 82 times

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13323
Joined: Tue Sep 16, 2008 5:38 pm

Re: multiple density plot on the same graph

Postby EViews Gareth » Wed Sep 13, 2023 8:54 am

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?
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 33 guests