| Title: | An Alternative to the Hodrick-Prescott Filter |
|---|---|
| Description: | In the working paper titled "Why You Should Never Use the Hodrick-Prescott Filter", James D. Hamilton proposes a new alternative to economic time series filtering. The neverhpfilter package provides functions and data for reproducing his work. Hamilton (2017) <doi:10.3386/w23429>. |
| Authors: | Justin M. Shea [aut, cre] |
| Maintainer: | Justin M. Shea <[email protected]> |
| License: | GPL-3 |
| Version: | 0.5-0 |
| Built: | 2026-05-21 07:34:52 UTC |
| Source: | https://github.com/justinmshea/neverhpfilter |
EXPGSC1 Real Exports of Goods and Services
data(EXPGSC1)data(EXPGSC1)
An xts object of Real Exports of Goods and Services.
Release: Gross Domestic Product
Seasonal Adjustment: Seasonally Adjusted Annual Rate
Frequency: Quarterly
Units: Billions of Chained 2017 Dollars
Date Range: 1947-01-01 to 2025-04-01
BEA Account Code: A020RX
A Guide to the National Income and Product Accounts of the United States (NIPA) - (http://www.bea.gov/national/pdf/nipaguid.pdf)
U.S. Bureau of Economic Analysis https://fred.stlouisfed.org/data/EXPGSC1
data(EXPGSC1) tail(EXPGSC1) plot(EXPGSC1,grid.col = "white", col="blue")data(EXPGSC1) tail(EXPGSC1) plot(EXPGSC1,grid.col = "white", col="blue")
FEDFUNDS All Employees: Total Nonfarm
data(FEDFUNDS)data(FEDFUNDS)
An xts object of the Fed Funds figures.
Release: H.15 Selected Interest Rates
Seasonal Adjustment: Not Seasonally Adjusted
Frequency: Monthly
Units: Percent
Date Range: 1954-07-01 to 2025-07-01
Averages of daily figures.
The federal funds rate is the interest rate at which depository institutions trade federal funds (balances held at Federal Reserve Banks) with each other overnight. When a depository institution has surplus balances in its reserve account, it lends to other banks in need of larger balances. In simpler terms, a bank with excess cash, which is often referred to as liquidity, will lend to another bank that needs to quickly raise liquidity. (1) The rate that the borrowing institution pays to the lending institution is determined between the two banks; the weighted average rate for all of these types of negotiations is called the effective federal funds rate.(2) The effective federal funds rate is essentially determined by the market but is influenced by the Federal Reserve through open market operations to reach the federal funds rate target.(2) The Federal Open Market Committee (FOMC) meets eight times a year to determine the federal funds target rate. As previously stated, this rate influences the effective federal funds rate through open market operations or by buying and selling of government bonds (government debt). (2) More specifically, the Federal Reserve decreases liquidity by selling government bonds, thereby raising the federal funds rate because banks have less liquidity to trade with other banks. Similarly, the Federal Reserve can increase liquidity by buying government bonds, decreasing the federal funds rate because banks have excess liquidity for trade. Whether the Federal Reserve wants to buy or sell bonds depends on the state of the economy. If the FOMC believes the economy is growing too fast and inflation pressures are inconsistent with the dual mandate of the Federal Reserve, the Committee may set a higher federal funds rate target to temper economic activity. In the opposing scenario, the FOMC may set a lower federal funds rate target to spur greater economic activity. Therefore, the FOMC must observe the current state of the economy to determine the best course of monetary policy that will maximize economic growth while adhering to the dual mandate set forth by Congress. In making its monetary policy decisions, the FOMC considers a wealth of economic data, such as: trends in prices and wages, employment, consumer spending and income, business investments, and foreign exchange markets.
The federal funds rate is the central interest rate in the U.S. financial market. It influences other interest rates such as the prime rate, which is the rate banks charge their customers with higher credit ratings. Additionally, the federal funds rate indirectly influences longer- term interest rates such as mortgages, loans, and savings, all of which are very important to consumer wealth and confidence.(2)
References (1) Federal Reserve Bank of New York. “Federal funds.” Fedpoints, August 2007. (2) Board of Governors of the Federal Reserve System. “Monetary Policy”. http://www.federalreserve.gov/monetarypolicy/default.htm.
Board of Governors of the Federal Reserve System (US) https://fred.stlouisfed.org/data/FEDFUNDS
data(FEDFUNDS) tail(FEDFUNDS) plot(FEDFUNDS, grid.col = "white", col="green")data(FEDFUNDS) tail(FEDFUNDS) plot(FEDFUNDS, grid.col = "white", col="green")
GCEC1 Real Government Consumption Expenditures and Gross Investment
data(GCEC1)data(GCEC1)
An xts object containing observations of Real Exports of Goods and Services.
Release: Gross Domestic Product
Seasonal Adjustment: Seasonally Adjusted Annual Rate
Frequency: Quarterly
Units: Billions of Chained 2017 Dollars
Date Range: 1947-01-01 to 2025-04-01
BEA Account Code: A822RX
A Guide to the National Income and Product Accounts of the United States (NIPA) - (http://www.bea.gov/national/pdf/nipaguid.pdf)
U.S. Bureau of Economic Analysis https://fred.stlouisfed.org/data/GCEC1
data(GCEC1) tail(GCEC1) plot(GCEC1, grid.col = "white", col="blue")data(GCEC1) tail(GCEC1) plot(GCEC1, grid.col = "white", col="blue")
GDPC1 Real Gross Domestic Product
data(GDPC1)data(GDPC1)
An xts object of Real Gross Domestic Product.
Release: Gross Domestic Product
Seasonal Adjustment: Seasonally Adjusted Annual Rate
Frequency: Quarterly
Units: Billions of Chained 2017 Dollars
Date Range: 1947-01-01 to 2025-04-01
Real gross domestic product is the inflation adjusted value of the goods and services produced by labor and property located in the United States.
For more information see the Guide to the National Income and Product Accounts of the United States (NIPA) - https://www.bea.gov/resources/methodologies/nipa-handbook.
BEA Account Code: A191RX
U.S. Bureau of Economic Analysis https://fred.stlouisfed.org/data/GDPC1
data(GDPC1) log_RGDP <- 100*log(GDPC1) gdp_cycle <- yth_filter(log_RGDP, h = 8, p = 4, output = c("cycle", "random"), family = gaussian) main <- "Log of Real GDP cycle and random walk" plot(gdp_cycle, grid.col = "white", legend.loc = "topright", main = main)data(GDPC1) log_RGDP <- 100*log(GDPC1) gdp_cycle <- yth_filter(log_RGDP, h = 8, p = 4, output = c("cycle", "random"), family = gaussian) main <- "Log of Real GDP cycle and random walk" plot(gdp_cycle, grid.col = "white", legend.loc = "topright", main = main)
GDPDEF Gross Domestic Product: Implicit Price Deflator
data(GDPDEF)data(GDPDEF)
An xts object containing quarterly observations of the
Gross Domestic Product: Implicit Price Deflator.
Gross Domestic Product
Seasonally Adjusted Annual Rate
Quarterly
Index 2017 = 100
1947-01-01 to 2025-04-01
BEA Account Code: A191RD
The number of decimal places reported varies over time. A Guide to the National Income and Product Accounts of the United States (NIPA) - (http://www.bea.gov/national/pdf/nipaguid.pdf)
U.S. Bureau of Economic Analysis https://fred.stlouisfed.org/data/GDPDEF
data(GDPDEF) head(GDPDEF) tail(GDPDEF) plot(GDPDEF, col = "blue")data(GDPDEF) head(GDPDEF) tail(GDPDEF) plot(GDPDEF, col = "blue")
GPDIC1 Real Gross Private Domestic Investment
data(GPDIC1)data(GPDIC1)
An xts object containing quarterly observations of
Real Gross Private Domestic Investment.
Gross Domestic Product
Seasonally Adjusted Annual Rate
Quarterly
Billions of Chained 2017 Dollars
1947-01-01 to 2025-04-01
BEA Account Code: A006RX
A Guide to the National Income and Product Accounts of the United States (NIPA) - (http://www.bea.gov/national/pdf/nipaguid.pdf)
U.S. Bureau of Economic Analysis https://fred.stlouisfed.org/data/GPDIC1
data(GPDIC1) tail(GPDIC1) plot(GPDIC1, grid.col = "white", col = "blue")data(GPDIC1) tail(GPDIC1) plot(GPDIC1, grid.col = "white", col = "blue")
GS10 10-Year Treasury Constant Maturity Rate
data(GS10)data(GS10)
An xts object containing observations of the
10-Year Treasury Constant Maturity Rate.
H.15 Selected Interest Rates
Not Seasonally Adjusted
Monthly
Percent
1953-04-01 to 2025-07-01
Averages of business days.
For further information regarding treasury constant maturity data, please refer to: - http://www.federalreserve.gov/releases/h15/current/h15.pdf - http://www.treasury.gov/resource-center/data-chart-center/interest-rates/Pages/yieldmethod.aspx
Board of Governors of the Federal Reserve System (US) https://fred.stlouisfed.org/data/GS10
data(GS10) tail(GS10) plot(GS10, grid.col = "white", col = "green")data(GS10) tail(GS10) plot(GS10, grid.col = "white", col = "green")
Standard deviation of cyclical component and correlation with cyclical component of GDP for assorted macroeconomic series.
data("Hamilton_table_2")data("Hamilton_table_2")
A data.frame containing 13 economic time series observations
of 5 variables:
Standard deviation of the cycle component,
computed with function yth_filter(x, output = "cycle").
Correlation of cycle.sd with the cycle.sd of
100 * log(RealGDP).
Standard deviation of a random walk, computed by
rolling differencing the series by period h, the same h passed
to yth_filter(x, output = "cycle") to compute cycle.sd.
Correlation of random.sd with the random.sd
of 100 * log(RealGDP).
Filtered series were based on the full sample available for that variable, while correlations were calculated using the subsample of overlapping values for the two indicators. Note that the regression residuals lose the first 11 observations and the random-walk calculations lose the first 8 observations.
Hamilton, James D. (2018). *Why You Should Never Use the Hodrick-Prescott Filter*, pg. 40. http://econweb.ucsd.edu/~jhamilto/hp.pdf
print(Hamilton_table_2)print(Hamilton_table_2)
IMPGSC1 Real Imports of Goods and Services
data(IMPGSC1)data(IMPGSC1)
An xts object containing quarterly observations of
Real Imports of Goods and Services.
Gross Domestic Product
Seasonally Adjusted Annual Rate
Quarterly
Billions of Chained 2017 Dollars
1947-01-01 to 2025-04-01
BEA Account Code: A021RX
A Guide to the National Income and Product Accounts of the United States (NIPA) - (http://www.bea.gov/national/pdf/nipaguid.pdf)
U.S. Bureau of Economic Analysis https://fred.stlouisfed.org/data/IMPGSC1
data(IMPGSC1) tail(IMPGSC1) plot(IMPGSC1, grid.col = "white", col = "blue")data(IMPGSC1) tail(IMPGSC1) plot(IMPGSC1, grid.col = "white", col = "blue")
PAYEMS All Employees: Total Nonfarm
data(PAYEMS)data(PAYEMS)
An xts object containing observations of
All Employees: Total Nonfarm.
Employment Situation
Seasonally Adjusted
Monthly
Thousands of Persons
1939-01-01 to 2025-07-01
All Employees: Total Nonfarm, commonly known as Total Nonfarm Payroll, is a measure of the number of U.S. workers in the economy that excludes proprietors, private household employees, unpaid volunteers, farm employees, and the unincorporated self-employed. This measure accounts for approximately 80 percent of the workers who contribute to Gross Domestic Product (GDP).
This measure provides useful insights into the current economic situation because it can represent the number of jobs added or lost in an economy. Increases in employment might indicate that businesses are hiring which might also suggest that businesses are growing. Additionally, those who are newly employed have increased their personal incomes, which means (all else constant) their disposable incomes have also increased, thus fostering further economic expansion.
Generally, the U.S. labor force and levels of employment and unemployment are subject to fluctuations due to seasonal changes in weather, major holidays, and the opening and closing of schools. The Bureau of Labor Statistics (BLS) adjusts the data to offset the seasonal effects to show non-seasonal changes: for example, women's participation in the labor force; or a general decline in the number of employees, a possible indication of a downturn in the economy. To closely examine seasonal and non-seasonal changes, the BLS releases two monthly statistical measures: the seasonally adjusted All Employees: Total Nonfarm (PAYEMS) and All Employees: Total Nonfarm (PAYNSA), which is not seasonally adjusted.
The series comes from the 'Current Employment Statistics (Establishment Survey).
The source code is: CES0000000001
U.S. Bureau of Labor Statistics https://fred.stlouisfed.org/data/PAYEMS
data(PAYEMS) tail(PAYEMS) PAYEMS_qtr <- xts::to.quarterly(PAYEMS["1947/"], OHLC = FALSE) log_Employment <- 100*log(PAYEMS_qtr) employ_trend <- yth_filter(log_Employment, h = 8, p = 4, output = c("x", "trend"), family = gaussian) main <- "Log of Employment and trend" plot(employ_trend, grid.col = "white", legend.loc = "topleft", main = main) employ_cycle <- yth_filter(log_Employment, h = 8, p = 4, output = c("cycle", "random"), family = gaussian) main <- "Log of Employment cycle and random walk" plot(employ_cycle, grid.col = "white", legend.loc = "topright", main = main)data(PAYEMS) tail(PAYEMS) PAYEMS_qtr <- xts::to.quarterly(PAYEMS["1947/"], OHLC = FALSE) log_Employment <- 100*log(PAYEMS_qtr) employ_trend <- yth_filter(log_Employment, h = 8, p = 4, output = c("x", "trend"), family = gaussian) main <- "Log of Employment and trend" plot(employ_trend, grid.col = "white", legend.loc = "topleft", main = main) employ_cycle <- yth_filter(log_Employment, h = 8, p = 4, output = c("cycle", "random"), family = gaussian) main <- "Log of Employment cycle and random walk" plot(employ_cycle, grid.col = "white", legend.loc = "topright", main = main)
PCECC96 Real Personal Consumption Expenditures
data(PCECC96)data(PCECC96)
An xts object containing quarterly observations of
Real Personal Consumption Expenditures.
Gross Domestic Product
Seasonally Adjusted Annual Rate
Quarterly
Billions of Chained 2017 Dollars
1947-01-01 to 2025-04-01
BEA Account Code: DPCERX
A Guide to the National Income and Product Accounts of the United States (NIPA) - (http://www.bea.gov/national/pdf/nipaguid.pdf)
U.S. Bureau of Economic Analysis https://fred.stlouisfed.org/data/PCECC96
data(PCECC96) tail(PCECC96) plot(PCECC96, grid.col = "white", col = "blue")data(PCECC96) tail(PCECC96) plot(PCECC96, grid.col = "white", col = "blue")
SP500 Robert Shiller's data set for U.S. Stock Markets 1871–2021 and CAPE Ratio.
data(SP500)data(SP500)
An xts object containing observations of U.S. Stock Markets
1871–Present and CAPE Ratio.
Monthly
1871-01 to 2023-09
Nominal prices of the S&P composite index, April 2021 observation is 04/05 close
Nominal dividends
Nominal earnings, S&P 500 estimated
Shiller's Consumer Price Index data used for transformation to real prices
Shiller's Long-term interest rate, 10-Year Treasury Constant Maturity Rate, April 2021 observation is 04/05 close
Real prices of the S&P 500 composite index
Real dividends
Real total return price of the S&P 500 composite index
Real earnings
Real total return scaled earnings
Cyclically Adjusted Price Earnings Ratio (P/E10 or CAPE)
Cyclically Adjusted Total Return Price Earnings Ratio (P/E10_TR or CAPE_TR)
Excess CAPE Yield
Total bond returns
Real total bond returns
This data set consists of monthly stock price, dividends, and earnings data and the consumer price index (to allow conversion to real values), all starting January 1871. The price, dividend, and earnings series are from the same sources as described in Chapter 26 of my earlier book (Market Volatility, Cambridge, MA: MIT Press, 1989), although now I use monthly data, rather than annual data.
Monthly dividend and earnings data are computed from the S&P four-quarter totals for the quarter since 1926, with linear interpolation to monthly figures. Dividend and earnings data before 1926 are from Cowles and associates (Common Stock Indexes, 2nd ed., Bloomington, Ind.: Principia Press, 1939), interpolated from annual data. Stock price data are monthly averages of daily closing prices.
The CPI-U (Consumer Price Index–All Urban Consumers) published by the U.S. Bureau of Labor Statistics begins in 1913; for years before 1913, Shiller spliced Warren and Pearson's price index by multiplying it by the ratio of the indexes in January 1913. December 1999 and January 2000 values for the CPI-U are extrapolated. See George F. Warren and Frank A. Pearson, *Gold and Prices* (New York: John Wiley and Sons, 1935). Data are from their Table 1, pp. 11–14.
Shiller, Robert J. *Irrational Exuberance*, Princeton University Press 2000, Broadway Books 2001, 2nd ed. 2005, 3rd ed. 2015. http://www.econ.yale.edu/~shiller/data.htm
Download .xls file directly from here: http://www.econ.yale.edu/~shiller/data/ie_data.xls
data(SP500) SP500_qtr <- xts::to.quarterly(SP500$SP500, OHLC = FALSE) log_SP500 <- 100*log(SP500_qtr) SP500_trend <- yth_filter(log_SP500, h = 8, p = 4, output = c("x", "trend"), family = gaussian) main <- "Log of SP500 and trend" plot(SP500_trend, grid.col = "white", legend.loc = "topleft", main = main) SP500_cycle <- yth_filter(log_SP500["1900/"], h = 8, p = 4, output = c("cycle", "random"), family = gaussian) main <- "Log of SP500 cycle and random walk" plot(SP500_cycle, grid.col = "white", legend.loc = "topright", main = main)data(SP500) SP500_qtr <- xts::to.quarterly(SP500$SP500, OHLC = FALSE) log_SP500 <- 100*log(SP500_qtr) SP500_trend <- yth_filter(log_SP500, h = 8, p = 4, output = c("x", "trend"), family = gaussian) main <- "Log of SP500 and trend" plot(SP500_trend, grid.col = "white", legend.loc = "topleft", main = main) SP500_cycle <- yth_filter(log_SP500["1900/"], h = 8, p = 4, output = c("cycle", "random"), family = gaussian) main <- "Log of SP500 cycle and random walk" plot(SP500_cycle, grid.col = "white", legend.loc = "topright", main = main)
UNRATENSA Civilian Unemployment Rate
data(UNRATENSA)data(UNRATENSA)
An xts object containing monthly observations of the
Civilian Unemployment Rate.
Employment Situation
Not Seasonally Adjusted
Monthly
Percent
1948-01-01 to 2025-07-01
The unemployment rate represents the number of unemployed as a percentage of the labor force. Labor force data are restricted to people 16 years of age and older, who currently reside in one of the 50 states or the District of Columbia, who do not reside in institutions (e.g., penal and mental facilities, homes for the aged), and who are not on active duty in the Armed Forces.
This rate is also defined as the U-3 measure of labor underutilization.
The series comes from the 'Current Population Survey (Household Survey)'.
The source code is: LNU04000000
U.S. Bureau of Labor Statistics https://fred.stlouisfed.org/data/UNRATENSA
data(UNRATENSA) tail(UNRATENSA) plot(UNRATENSA, grid.col = "white", col = "green")data(UNRATENSA) tail(UNRATENSA) plot(UNRATENSA, grid.col = "white", col = "green")
USREC NBER based Recession Indicators for the United States from the
period following the peak through the trough.
data(USREC)data(USREC)
An xts object containing monthly observations of
NBER-based Recession Indicators.
Recession Indicators Series (Not a press release)
Not Seasonally Adjusted
Monthly
Binary indicator (1 = recession, 0 = expansion)
1854-12-01 to 2025-07-01
This time series is an interpretation of U.S. Business Cycle Expansions and Contractions data provided by The National Bureau of Economic Research (NBER) at http://www.nber.org/cycles/cyclesmain.html.
The series is composed of dummy variables that represent periods of expansion and recession. A value of 1 indicates a recessionary period, while a value of 0 indicates an expansionary period.
The NBER identifies months and quarters of turning points without designating an exact date within the period that turning points occurred. For this time series, the recession begins the first day of the period following a peak and ends on the last day of the period of the trough.
Three methods of interpretation are used for converting peak/trough dates into shaded recession data:
Midpoint method — recession spans midpoints of peak and trough.
Trough method — recession spans from period following the peak through the trough (used for this series and in FRED).
Peak method — recession spans from peak through the period preceding the trough.
Federal Reserve Bank of St. Louis https://fred.stlouisfed.org/data/USREC
data(USREC) USREC["2007/2009"] plot(USREC["1947/"], grid.col = "white", col = "red")data(USREC) USREC["2007/2009"] plot(USREC["1947/"], grid.col = "white", col = "red")
yth_filter returns an xts object containing
user-defined combinations of the original, trend, cycle, and random walk series.
yth_filter(x, h = 8, p = 4, output = c("x", "trend", "cycle", "random"), ...)yth_filter(x, h = 8, p = 4, output = c("x", "trend", "cycle", "random"), ...)
x |
A univariate |
h |
An |
p |
An |
output |
A |
... |
Other arguments passed to |
For time series of quarterly periodicity, Hamilton suggests parameters of
h = 8 and p = 4, or an process, additionally lagged by
lookahead periods. Econometricians may explore variations of h. However, p
is designed to correspond with the seasonality of a given periodicity and
should be matched accordingly.
An xts object defined by the output parameter.
James D. Hamilton. Why You Should Never Use the Hodrick-Prescott Filter. NBER Working Paper No. 23429, Issued in May 2017.
data(GDPC1) gdp_filter <- yth_filter(100*log(GDPC1), h = 8, p = 4) head(gdp_filter, 15) #---------------------------------------------------------------------------# data(PAYEMS) log_Employment <- 100*log(xts::to.quarterly(PAYEMS["1947/2016-6"], OHLC = FALSE)) employ_trend <- yth_filter(log_Employment, h = 8, p = 4, output = c("x", "trend")) plot(employ_trend, grid.col = "white", legend.loc = "topleft", main = "Log of Employment and trend") #----------------------------------------------------------------------------# quarterly_data <- 100*log(merge(GDPC1, PCECC96, GPDIC1, EXPGSC1, IMPGSC1, GCEC1, GDPDEF)) cycle <- do.call(merge, lapply(quarterly_data, yth_filter, output = "cycle")) random <- do.call(merge, lapply(quarterly_data, yth_filter, output = "random")) cycle.sd <- t(data.frame(lapply(cycle, sd, na.rm = TRUE))) GDP.cor <- t(data.frame(lapply(cycle, cor, cycle[,1], use = "complete.obs"))) random.sd <- t(data.frame(lapply(random, sd, na.rm = TRUE))) random.cor <- t(data.frame(lapply(random, cor, random[,1], use = "complete.obs"))) my_table_2 <- round(data.frame(cbind(cycle.sd, GDP.cor, random.sd, random.cor)), 2) names(my_table_2) <- names(Hamilton_table_2)[1:4] my_table_2data(GDPC1) gdp_filter <- yth_filter(100*log(GDPC1), h = 8, p = 4) head(gdp_filter, 15) #---------------------------------------------------------------------------# data(PAYEMS) log_Employment <- 100*log(xts::to.quarterly(PAYEMS["1947/2016-6"], OHLC = FALSE)) employ_trend <- yth_filter(log_Employment, h = 8, p = 4, output = c("x", "trend")) plot(employ_trend, grid.col = "white", legend.loc = "topleft", main = "Log of Employment and trend") #----------------------------------------------------------------------------# quarterly_data <- 100*log(merge(GDPC1, PCECC96, GPDIC1, EXPGSC1, IMPGSC1, GCEC1, GDPDEF)) cycle <- do.call(merge, lapply(quarterly_data, yth_filter, output = "cycle")) random <- do.call(merge, lapply(quarterly_data, yth_filter, output = "random")) cycle.sd <- t(data.frame(lapply(cycle, sd, na.rm = TRUE))) GDP.cor <- t(data.frame(lapply(cycle, cor, cycle[,1], use = "complete.obs"))) random.sd <- t(data.frame(lapply(random, sd, na.rm = TRUE))) random.cor <- t(data.frame(lapply(random, cor, random[,1], use = "complete.obs"))) my_table_2 <- round(data.frame(cbind(cycle.sd, GDP.cor, random.sd, random.cor)), 2) names(my_table_2) <- names(Hamilton_table_2)[1:4] my_table_2
yth_glm fits a generalized linear model suggested by James D. Hamilton
as a better alternative to the Hodrick-Prescott Filter.
yth_glm(x, h = 8, p = 4, ...)yth_glm(x, h = 8, p = 4, ...)
x |
A univariate |
h |
An |
p |
An |
... |
Additional arguments passed to |
For time series of quarterly periodicity, Hamilton suggests parameters of
h = 8 and p = 4, or an process, additionally lagged by
lookahead periods. Econometricians may explore variations of h. However, p is
designed to correspond with the seasonality of a given periodicity and should
be matched accordingly.
yth_glm returns a generalized linear model object of class
glm, which inherits from lm.
James D. Hamilton. Why You Should Never Use the Hodrick-Prescott Filter. NBER Working Paper No. 23429, Issued in May 2017.
data(GDPC1) gdp_model <- yth_glm(GDPC1, h = 8, p = 4, family = gaussian) summary(gdp_model) plot(gdp_model)data(GDPC1) gdp_model <- yth_glm(GDPC1, h = 8, p = 4, family = gaussian) summary(gdp_model) plot(gdp_model)