11
$\begingroup$

Mathematica V10.4 supports a service for connection to FRED. If you create a connection with

fred = ServiceConnect["FederalReserveEconomicData"]

(you need to have created a login id to be successful), and then ask for the US Unemployment data

ds = fred["SeriesSearch", "Query" -> "UNRATE"]

you will get a dataset with nine elements: title, frequency, units, etc. Everything but the unemployment time series. I suppose I just don't know how to use the FRED service connection, but the current documentation doesn't help. Does anyone know how to use this wonderful new datasource?

$\endgroup$
  • 1
    $\begingroup$ George it is not too hard to write some code to use this if you have ongoing problems with the built in function library.wolfram.com/infocenter/MathSource/7583 $\endgroup$ – Mike Honeychurch Mar 6 '16 at 0:51
  • $\begingroup$ I think the problem is that the query returned everything but data. I probably didn't use the right parameters. Thanks for the link, and I'll probably work with it just to see how it works, but I really want to use the ServiceConnect function. $\endgroup$ – George Wolfe Mar 6 '16 at 2:30
  • $\begingroup$ @MikeHoneychurch Got your code. Beautiful and instructive. 2 problems: (1) FRED now protected symbol-changed to FREDX; (2) Cases[tmp, {x : {?NumericQ, _, _, __}, y?NumericQ, ___} -> {x, y}, [Infinity]] doesn't work-I can't identify the problem. $\endgroup$ – George Wolfe Mar 6 '16 at 16:03
  • $\begingroup$ The code was written 6 years ago so there may have been some API changes. The API was well documented so it should not be too difficult to work out the problems or start from scratch $\endgroup$ – Mike Honeychurch Mar 6 '16 at 22:53
5
$\begingroup$

And the answer is:

fred = ServiceConnect["FederalReserveEconomicData"]
ts = fred["SeriesData", "ID" -> "UNRATE"];
DateListPlot[ts, GridLines -> Automatic, PlotLabel -> "US Unemployment Rate"]

enter image description here

ServiceConnect should accept a login id, but I can't get that to work. When I evaluate ServiceConnect["..."] it opens an authentication dialog box at the Fred's website. That part is missing from the steps shown above.

The 10.4 documentation is helpful, but Mike Honeychurch's link deserves careful study, as it provide insight into the variety of data that the FRED service returns and good code examples.

There are two types of requests: "SeriesSearch" and "SeriesData" (if documentation is correct). SeriesSearch accepts parameters "Query", "Frequency", "Units", "SeasonalAdjustments", "MaxItems", "StartIndex"and "SortBy." Query should contain text strings for the search. SeriesData requests requires a series identifier (either from list above or one you already know), and will accept an optional date which can be either a starting date (I think) or a date range.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.