code
real-time data programs
- The following Perl and Matlab code transform real-time data from the St. Louis Fed's ALFRED system into vintage data arrays.
realtimeobservationdatamaker.pl realtimeobservationdatamaker.m
The usage is as follows:
- For a data series in ALFRED, go to the download page.
- Change "Observation Range" and "Select Vintage Dates..." as desired.
- Select Observations by Real-Time Period under "Output Format"
- Select Zipped Tab Delimited Text under "File Format"
- Extract the .zip to the suitable directory
- Run realtimeobservationdatamaker.pl (either in the suitable directory where the .zip extracted, or move the working directory when Perl asks). This purpose of the Perl script is to put everything into a .csv format that Matlab can read, including "NaN"s for empty spaces.
- The Perl scans the directory and reports .txt files that might be data files -- pick the one you want by typing the exact name
- Perl will say if it was successful -- if not successful, that's weird...
- In Matlab, put realtimeobservationdatamaker.m in your working directory or path and then call it like
- out = realtimeobservationdatamaker('DRIVE:\suitabledirectorypath\YOURPARTICULARDATASERIES_1_rfm.csv');
- Answer the prompts as you wish -- the default saving name is YOURPARTICULARDATASERIES_1_rfm_YOURCHOSENVINTAGEFREQUENCY in the directory where realtimeobservationdatamaker.m is located
The vintage data array is a structure with three fields. The ".x" field is the vintage data array itself, with observation dates running vertically and the vintage dates running horizontally. The ".t" field is the observation date time array, where years are in the first column, subunits of the year are in the second column, and subsubunits of the subunits are in the third column. The ".v" field is the vintage date time array, where years are in the first row, subunits of the year are in the second row, and the subsubunits of the subunits are in the third row.
firstreportedvalue.m also uses the files output by realtimeobservationdatamaker.pl. It creates a first-reported-value structure, with fields ".x" -- the data, ".t" -- the observation time, and ".tfr" -- time of first report. It gives you the opportunity to save the output structure: the default saving name is YOURPARTICULARDATASERIES_1_rfm_firstreportedvalue in the directory where firstreportedvalue.m is located. The freq it asks for is a vector with the frequency of the sub-year units: for example, the frequency vector for time arrays that are [year,month,day] is [12,31]; for [year,qtr,day], [4,93]; etc.
- For a data series in ALFRED, go to the download page.