Allin and I are working on automated data download from dbnomics (if you
don't know what I'm talking about: https://db.nomics.world). This led both
of us to using JSON object more systematically than we used to, and I have
to say JSON is very nice.
During my experiments, I wrote a little function for automatically
downloading datasets from DataHub (https://datahub.io). A small example
set verbose off
function string datahub_get(string URL, string filename[null])
s = readfile(URL)
printf "reading %s...\n", URL
printf "Dataset name: %s\n", jsonget(s, "$.title")
resources = jsonget(s, "$.resources..datahub.type")
got = 0
loop i = 1 .. nelem(resources) --quiet
string r = strstrip(jsonget(s, sprintf("$.resources[%d].datahub.type", i-1)))
if r == "derived/csv"
hit = i-1
got = 1
ret = filename
fname = sprintf("%04d.csv", randgen1(i,0,9999))
ret = sprintf("@dotdir\\%s", fname)
ret = sprintf("@dotdir/%s", fname)
printf "data URL found, reading...\n"
path = jsonget(s, sprintf("$.resources[%d].path", hit))
c = readfile(path)
outfile "@ret" --quiet --write
printf "No data found\n"
ret = ""
URL = "https://pkgstore.datahub.io/core/pharmaceutical-drug-spending/19/datapack..."
fname = datahub_get(URL)
Of course the function above can be enhanced in many ways, but the gist
is: once you have the URL to the dataset, the function will download the
data to a CSV file (you can supply a name if you want, otherwise a random
one will be generated for you). At that point, you may just open the CSV
How do you get the URLs for the datasets you want? Easy:
* Navigate to the page of the dataset you want (for example,
* scroll to the bottom and copy the URL corresponding to the
"Datapackage.json" button. In most cases, it's just the page URL with
"/datapackage.json" appended at the end (for example,
* run the function datahub_get() with the URL string as first parameter;
you maty supply an optional second parameter if you want to save the CSV
file to a location of your choice.
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
I am attaching a test script. For case 3 it works, but not for case 4, and as Sven said, nor for case 2.
P.S. In what concerns editing the plots, I did not find anything to change the color or he area in the GUI plot editor.
Dear Jack and Sven,
I am trying to estimate an SVECM subject to long run restrictions using the SVAR package (version 1.34, Gretl 2018a, Win 10). I found out that although cointegration case 3 (unrestricted constant) works well, case 4 (trend restricted to the cointegration space) produces the following error message:
Matrices not conformable for operation*** error in function vecm_est, line 87
> matrix mu = olspar[1,] | (jalpha * jbeta[n+1,])'
called by function SVAR_estimate
Error executing script: halting
I restrict all the coefficients in beta beforehand. I also restrict those in alpha, but I don't think this is relevant.
Could you take a look on it?
Thank you in advance,
P.S. Is it possible to change the pink color in IRFs graphs from the SVAR package?