Description Usage Arguments Details Value Examples
Function that fetches economic data from the FRED based on the series ids.
1 2 3 4 5 6 7 8 9 |
... |
character vectors of series ids to search. Any names will be used to label the series in the resulting data.frame |
key |
32 character lower-cased alpha-numeric character string |
all |
logical; should all observations be used? Defaults to |
info |
logical; should information about each series, such as units and title, be kept? If so, the information will be stored in a data.frame under the attribute |
realtime_start, realtime_end |
character date strings of format "YYY-MM-DD" used obtain information that was known during the specified time period. If empty, the latest update of the information is used. |
long |
logical; should the resulting data.frame be long or wide? Defaults to |
The fred
function search for series ids from the FRED and returns the
values in a data.frame. Unless long=TRUE
, a new column will be created
for each series. The dates for each observation will be included in the "date"
column and will be of class "Date". Each series will be a numeric value.
If a series cannot be found, then it will be skipped and R will issue a warning.
To access ALFRED, or the archived Federal Reserve Economic Data, use the realtime_start
and realtime_end
arguments to specify a time frame. More details about
real time periods can be found at https://fred.stlouisfed.org/docs/api/fred/realtime_period.html.
data.frame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
api_key <- "abcdefghijklmnopqrstuvwxyz123456"
# Naive Phillips Curve Estimation
df <- fred(p = "CPIAUCSL", u = "u6rate", key=api_key)
head(df)
df$pi <- log(df$p) - log(c(NA, df$p[2:nrow(df)]))
reg_pc <- lm(pi ~ u, data = df)
summary(reg_pc)
# Different variations of the CPI
cpis <- c("CPIMEDSL", "CPIFABSL", "CPIHOSSL")
names(cpis) <- c("P_Med", "P_Food", "P_House")
df_cpi <- fred(cpis, key=api_key, long=TRUE)
head(df)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.