Description Format Source Examples
US Economic Data Series from FRED. The latest version of the data can be retrieved by running the example code. You need FRED API Key, which can be obtained here
Time series of class "ts"
.
https://fred.stlouisfed.org
FRED
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | ## Not run:
library(tsbox)
library(fredr)
library(bdfm)
# Use Sys.setenv(FRED_API_KEY = 'XXXX') to set FRED API Key.
# Obtain here: https://research.stlouisfed.org/docs/api/api_key.html
series_q <- c(
'A191RL1Q225SBEA', # 01 Real GDP, seasonally adjusted, quarterly, annualized % change
'W068RCQ027SBEA' # 02 Governemnt expenditures
)
series_m <- c(
'USSLIND', # 03 Federal Reserve leading index, monthly, percent
'PCEDG', # 04 persional consumption: durable goods, monthly, level
'PCEND', # 05 persional consumption: non-durable goods, monthly, level
'UMCSENT', # 06 Consumer Sentiment, monthly, delayed 1 month for free data
'UNRATE', # 07 Unemployment, monthly
'JTSJOL', # 08 Job openenings, total non-farm
'INDPRO', # 09 Industrial Production Index, monthly, level
'CSUSHPINSA', # 10 Case-Shiller home price index, monthly, two month lag, level
'HSN1F', # 11 New 1 family houses sold, level
'TSIFRGHT', # 12 Freight transportation index, monthly, 2-3 month lag, level
'FRGSHPUSM649NCIS', # 13 CASS freight index, level, not SA
'CAPUTLG2211S', # 14 Electricity usage, % capacity, monthly
'IPG2211S', # 15 Electricity, industrial production index, monthly, level
'DGORDER', # 16 New Orders, durable manufacturing goods, monthly, level
'AMTMNO', # 17 New Orderes, all manufacuring industries, level
'MNFCTRIRSA', # 18 Manufacturers inventories:sales ratio
'RETAILIRSA', # 19 Retail inventories:sales ratio
'WHLSLRIRSA', # 20 Wholesalers, inventories:sales ratio
'CPILFESL' # 21 CPI
)
series_wd <- c(
'ICSA', # 22 Initial claims, SA, weekly
'TWEXB', # 23 exchange rate index, weekly
'T10Y3M' # 24 10Y to 3M treasury spread, daily
)
multi_fredr <- function(x, by = 0, frequency = NULL) {
z <- lapply(x, fredr, observation_start = as.Date("1980-01-01"), frequency = frequency)
lapply(z, ts_lag, by = by)
}
econ_us <- ts_ts(do.call(rbind, c(
multi_fredr(series_q, by = "2 month"),
multi_fredr(series_m),
multi_fredr(series_wd, frequency = "m")
)
))
# A lot of our data is already seasonally adjusted. We actually only need to SA
# three series (though whether it's necessary to adjust consumer sentiment is
# debatable).
series_sa <- c('UMCSENT', 'CSUSHPINSA', 'FRGSHPUSM649NCIS')
econ_us_sa <- do.call(cbind, lapply(
ts_tslist(econ_us[, series_sa]),
function(e) seas_we(e, lags = 3)$values
))
window(econ_us[, series_sa], end = end(econ_us_sa)) <- econ_us_sa
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.