代写ECON224 Macroeconomics II代做Statistics统计
- 首页 >> Python编程ECON224 Macroeconomics II
Research Project:
Macroeconomic Data Analysis and Understanding Business Cycle Facts
Roadmap
1 How to Detrend Macroeconomic Data?
2 HP Detrending with Stata
3 Business Cycles Facts in the UK
4 The Coursework
How to Detrend Macroeconomic Data?
Macroeconomic time series can be decomposed into a ‘trend component’ (gt) and a ‘cyclical component’ (ct).
For example for Real GDP Per Capita (Yt)
Let yt = lnYt
yt = gt +ct
How Can We Estimate gt and ct?
We only observe yt , but we want to extract the ‘trend’ and ‘cycle’ separately.
Two Common Approaches:
Linear Growth Trend (not recommended)
▶ Assumes GDP follows a deterministic trend.
▶ Ignores variations in long-run growth.
Hodrick-Prescott (HP) Filter (widely used)
▶ Separates trend from cyclical fluctuations.
▶ Smoothing parameter λ controls the flexibility of the trend.
Linear Trend
Assume the trend is linear – straight line
gt = β0 +β1t
We choose β0 and β1 to minimize:
The Evolution of log GDP and the growth trend
HP Filter
HP filter allows for variations over time in the underlying growth trend.
We choose to minimize:
The weighting parameter λ in the HP filter
When λ approaches 0, then the first item in the objective function dominates, that is, It ensures that gt closely follows yt .
To achieve the minimum, the optimal trend component gt is such that gt = yt . Then the minimum is 0.
When λ approaches +∞, then the second item in the objective function dominates, that is, It penalizes variations in the trend, that is to ensure a smooth trend.
To achieve the minimum, the optimal trend component is linear trend, that is, gt = β0 +β1t. The reason is, with the linear trend,
(gt+1 −gt)−(gt −gt−1) = β1 −β1 = 0,
and the optimum is 0.
The smoothing parameter λ controls the trade-off between goodness-of-fit and smoothness of the trend. The choice of the smoothing parameter λ is crucial and depends on the frequency of the data. In general
For monthly data, we choose λ = 14400
For quarterly data, we choose λ = 1600
For annual data, we choose λ = 100
The Evolution of log GDP and the growth trend
The Cyclical Component of log GDP
HP Detrending with Stata
Getting Started with Stata and Your Data
Stata is a user-friendly statistical software with both a menu-driven interface and a command-based mode.
Extensive online documentation and resources are available via Stata’s built-in help system or online searches.
Step 1: Load and Check Your Data
Download the data file from the webpage and check for missing years and ensure that the data appears reasonable
Load it into Stata.
Step 2: Renaming Variables (Optional)
You can rename variables for clarity:
Renaming Variables
rename pop N
rename gdp Y
Note that Stata’s variable names are case-sensitive (e.g., GDP, Gdp, and gdp are different variables)
Step 3: Creating New Variables
To create a new variable for the natural log of real GDP per capita:
Generating Log GDP per Capita
gen y = ln(Y/N)
Step 4: Defining the Time Structure
Stata needs to recognize the time dimension of your dataset for time-series analysis.
Use the tsset command to define the time variable (e.g., T represents time):
Setting Time Variable
tsset T
Step 5: Applying HP Filter in Stata
HP Filter Syntax
tsfilter hp new_cycle = original_series,
trend(new_trend) smooth(λ)
Example: Applying the HP filter to variable y with smoothing parameter λ = 100:
Example Command
tsfilter hp ychp = y, trend(ytrendhp) smooth(100)
This command:
▶ Creates a new variable ’ytrendhp’ containing the estimated trend component.
▶ Creates a new variable ’ychp’ containing the cyclical component.
Step 6: Visualizing HP Filter Output in Stata
To plot the original data and trend:
Plot GDP and Trend
twoway (line y T) (line ytrendhp T), title("HP
Filter Trend")
To plot the cyclical component:
Plot GDP Cycle
twoway line ychp date, title("HP Filter Cycle")
Analyzing Business Cycle Volatility and Comovement
1. Compute Correlation between Output and Consumption Cycles
To calculate the correlation between the cyclical components of output (‘ychp‘) and consumption (‘cchp‘), use:
Stata Command
corr ychp cchp
This provides the correlation coefficient, indicating the comovement of the two series.
2. Compute Standard Deviations of the Cyclical Components
To compute the standard deviation of each series:
Stata Commands
sum ychp, detail
sum cchp, detail
The standard deviation measures the volatility of output and consumption fluctuations.
3. Plot the Two Cyclical Components
To visualize the cyclical behavior. of output and consumption, use:
Stata Command
twoway (line ychp T) (line cchp T), title("Cyclical
Components of Output and Consumption")
legend(label(1 "Output") label(2 "Consumption"))
This command generates a time-series plot with ‘ychp‘ and ‘cchp‘ over time T.
Business Cycle Facts in the UK
Business Cycle Facts in the UK
By Keith Blackburn & Morten Ravn (Economica, 1992)
The paper examines UK business cycles from 1956 to 1990 using quarterly, detrended data on key aggregate variables.
The study identifies key empirical regularities in macroeconomic fluctuations.
It also compares UK business cycles with those of other economies.
The Coursework
Macroeconomic Data Analysis and Understanding Business Cycle Facts
Step 1: Select a Country
▶ Choose a country of interest.
▶ Download relevant macroeconomic variables.
Data Sources:
▶ Penn World Table - provides aggregate macroeconomic data.
▶ You are encouraged to explore other sources. A list of websites offering free datasets can be found at: Economics Network Data Sets.
Step 2: Data Analysis
▶ Detrend the data using the HP filter.
▶ Examine empirical regularities in macroeconomic fluctuations.
Selected Variables
▶ Aggregate variables: GDP, Consumption, Capital Stock (Investment), Employment, Hours Worked, Total Factor Productivity (TFP), etc.
▶ Disaggregated data: Durable Goods, Non-Durable Goods and Services, Residential Investment, Non-Residential Investment, etc.
▶ You may also explore additional macroeconomic variables relevant to your analysis.
Step 3: Analyze and Discuss Your Findings
Here are some ideas:
▶ Compare your findings with business cycle facts from other economies. Note: You do not need to replicate the analyses conducted in other studies; instead, simply cite relevant literature when making comparisons.
▶ Investigate how empirical regularities vary over time.
▶ Discuss possible explanations for your observations or highlight puzzling empirical facts.
▶ Focus on a specific business cycle event (e.g., the 2008-09 financial crisis or during Covid).
Step 4: Presentation and Submission
▶ Create a well-structured presentation slide.
▶ Present your analysis and record your presentation (5 minutes).
▶ Submit the recorded presentation on Canvas.
A submission link will be available in the Assignments folder on Canvas approximately two weeks before the deadline.
If you experience any issues with submission, please contact me at [email protected].
The research project is an independent assignment for each student.
The research report accounts for 20% of the module mark.
Deadline: Thursday, 1st May at 2:00 PM.