- In order to do this problem you will need the dataset titled canada quarterly.csv. This dataset contains quarterly observations on elements of GDP, labour market indicators, the price level, inflation and interest rates. You can do the assignment using a statistical package of your choosing. I have provided example codes in R.
- Make well labelled plots of consumption, investment, government spending, exports, imports, the inflation rate and the real interest rate. Which of these variables do you think need to be de-trended? Note that you will need to construct the inflation rate and the real interest rate from the available data using the definitions given in class.
Answer: De-trend is removing a trend from a time series and a trend always refers to a change in the mean over time.from those plots we need to de-trend consumption, investment, government spending, exports, imports.
plot of consumption

plot of investment

plot of government spending

plot of exports

plot of imports

plot of inflation rate
## Warning: Removed 1 row(s) containing missing values (geom_path).

plot of real interest rate
## Warning: Removed 1 row(s) containing missing values (geom_path).

Plot Multiple Time series

- Which of the series that you plotted would be easier to interpret on a log scale? Re-createyour graphs using a log scale in these cases and interpret the slopes.
answer: I think consumption, exports, government spending, imports and investment are easier to interpret on a log scale.
Canadian log-Quarterly consumption: Time Trend

Canadian log-Quarterly Investment: Time Trend

Canadian log-Quarterly Government Spending: Time Trend

Canadian log-Quarterly Exports: Time Trend

Canadian log-Quarterly Imports: Time Trend

- Use the HP Filter to de-trend the logarithms of the variables that you identified in part (a). Plot the cycle componenet and interprete the values. Be sure to use the appropriate value for λ.
#Cyclical Component of Canadian Quarterly Consumption 
#Cyclical Component of Canadian Quarterly Investment 
#Cyclical Component of Canadian Quarterly Government Spending 
#Cyclical Component of Canadian Quarterly Exports 
#Cyclical Component of Canadian Quarterly Imports 
(d)Name one drawback of the HP Filter and list the appropriate values for λ for monthly,quarterly and annual data.
Answer:HP Filter introduces spurious correlations that have no basis in the true data-generating process. Monthly: λ = 14400 quarterly: λ = 1600 annual: λ=100