[Gretl-users] FEVD graphs using code

Matteo Pelagatti matteo.pelagatti at unimib.it
Sat Nov 26 17:49:59 EST 2016


Thank you very much, Allin
Matteo

Il 26/11/2016 17:13, Allin Cottrell ha scritto:
> On Sat, 26 Nov 2016, Matteo Pelagatti wrote:
>
>> Dear Gretlers,
>>
>> is there a way to produce the stacked-bars Forecast Error Variance 
>> Decomposition (after having estimated a VAR or VECM) using the code?
>>
>> I can read the gnuplot code that generates the graph, but I cannot 
>> obtain the Gretl code that produces the gnuplot code.
>>
>> Thanks and all the best,
>
> The underlying code that generates the gnuplot script is in the C 
> source graphing.c. At present we don't have a user-accessible function 
> that does an FEVD plot, but such a thing can be written in hansl. 
> Here's a simple example:
>
> <hansl>
> open data9-7.gdt
> list X = PRIME UNEMP
> scalar p = nelem(X)
> var 4 X
>
> # grab FEVD for the first variable in the VAR,
> # in percentage form
> matrix F1 = 100 * $fevd[,1:p]
> scalar h = rows(F1)
> # get an array of strings holding the X-names
> strings vnames = varnames(X)
>
> # now open a plot file and write into it
> outfile "fevdtest.plt" --write --quiet
> printf "set xlabel 'quarters'\n"
> printf "set title 'FEVD for %s'\n", vnames[1]
> printf "set key outside\n"
> printf "set style fill solid 0.35\n"
> printf "set style histogram rowstacked\n"
> printf "set style data histogram\n"
> printf "set xrange [-0.5:%.1f]\n", h - 0.5
> printf "set yrange [0:100]\n"
> printf "plot \\\n"
> loop i=1..p --quiet
>   printf "'-' using 2 title '%s'", vnames[i]
>   if i < p
>     printf ", \\\n"
>   else
>     printf "\n"
>   endif
> endloop
> loop i=1..p --quiet
>   loop t=1..h --quiet
>     printf "%d %g\n", t-1, F1[t,i]
>   endloop
>   printf "e\n"
> endloop
> outfile --close
> </hansl>
>
> After running the above you should have a file fevdtest.plt that be 
> processed by gnuplot.
>
> The chunk of code that writes the plot file could be made more general 
> and wrapped into a function, if wanted.
>
> Allin
> _______________________________________________
> Gretl-users mailing list
> Gretl-users at lists.wfu.edu
> http://lists.wfu.edu/mailman/listinfo/gretl-users
>


-- 
Matteo Pelagatti
Dipartimento di Economia, Metodo Quantitativi e Stretegie di Impresa
Università degli Studi di Milano-Bicocca
Via Bicocca degli Arcimboldi, 8
20126 Milano
Tel +39 02 6448.5834
http://www.statistica.unimib.it/utenti/p_matteo/



More information about the Gretl-users mailing list