# ECON403 – Econometrics 2

Prerequisite: ECON305 (751305)

E-mail: me@pairach.com

## Course Description

Basic econometric tools, Econometrics for time series, cross sectional, and panel data, Econometric tools for other analyses.

## Course outline

This course will follow Part 2 and Part 3 of Wooldridge’s (2012) Introductory Econometrics: A Modern Approach.

Midterm parts

• Chapter 10: Basic Regression Analysis with Time Series Data
• Chapter 11: Further Issues in Using OLS with Time Series Data
• Chapter 12: Serial Correlation and Heteroskedasticity in Time Series Regressions

Final Parts

• Chapter 13: Time Series decomposition
• Chapter 14: Time series decomposition using Excel
• Chapter 15: Time series decomposition with R

## Schedule

Week 1: Introduction
Fri 5 Jan: Class introduction

• Course description and contents
• Schedule
• Assignments

Week 2: Chapter 10
Tue 9 Jan: Introduction to time series analysis with regression model

• List down 5 time series data in economics you are interested
• What are those data, why they are important and who are responsible to collect and manage those data
• Two approaches to apply regression models for time series data i.e., causal model (X as other factors) and time trend model (X as time). Seasonality extraction using dummy variable.

Wed 10 Jan: TES2018 Conference (Full day)
Fri 12 Jan: TES2018 Conference (Oral presentation)

Week 3: Chapter 10
Tue 16 Jan

• Basic Regression with R

R Code

```

# Sample of regression model

# call sample data in R
library(datasets)

?datasets
# call a list of datasets
library(help = "datasets")

data(mtcars)

mtcars
?mtcars

# Creating a linear regression model
# dependent var = mpg
# independent vars = hp, wt

# mpg = f(hp, wt)

?lm

# 1. create an object of reg model
model1 <- lm(mpg ~ hp, data = mtcars)

# 2. call a model summary
summary(model1)

# mpg = 30.09886 - 0.06829

# plot the model
plot(mtcars\$hp, mtcars\$mpg, col = "darkgreen")
abline(model1, col = "firebrick")

# check hypothesis
par(mfrow = c(2, 2))
plot(model1)

```

Tue 19 Jan

• Sample regression model with time series data

• R Code
```
# code
# Regression with time series data
# 1. Import dataset
# 2. Create a time serie object in R
mydata.ts <- ts(mydata, start = c(1960, 1),
end = c(2017, 1), frequency = 1)
# test plot ts data
plot(mydata.ts)
plot(mydata.ts,
main = "A Time Series Plot of Inflation, Unemployment, GDP and Population")
?plot
# see that data
mydata.ts
# 3. Develop a model
# 3.1 create an object to store the simple regression model
# dependent variable = inflation
# independent variable = unemployment
?lm
model1 <- lm(inflation ~ unemployment, data = mydata.ts)
summary(model1)
# Creating model 2 by adding population to model 1
model2	<- lm(inflation ~ unemployment + population, data = mydata.ts)
summary(model2)
# compare model1 vs model2
anova(model1, model2)
# Our final static time series model is:
# inflation = 2.5194 + 2.5194unemployment + 3.2230population
# R square = 0.3057

# post hoc hypothesis checking
par(mfrow = c(2, 2))
plot(model2)

```

Week 4: Chapter 10
Tue 23 Jan: Cancellation due to Graduation ceremony
Fri 26 Jan:

Workshop on running a regression model with time series data

Week 5: Workshop
Tue 30 Jan:

1) Normality check (pre-test)

```# import data

# assumpion checking

# 1. nornal distribution
names(mydata)

# normality check using boxplot
boxplot(mydata\$inflation)

# normality check using skewness
install.packages("psych")
library(psych)
skew(mydata\$inflation)
boxplot(mydata\$inflation, main ="skew(inflation = 2.167)")

# data transformation
# for positive skew, we may take a sqaure root first
boxplot(sqrt(mydata\$inflation))
skew(sqrt(mydata\$inflation))
boxplot(sqrt(mydata\$inflation), main ="skew(sqrt(inflation) = 0.676)")
# sqrt(inflation) is still positively skew,

# so we can take a logarithm
boxplot(log(mydata\$inflation))
skew(log(mydata\$inflation))
par(mfrow = c(1, 2)) # set output window to be 1x2
boxplot(mydata\$inflation, main ="skew(inflation = 2.167)")
boxplot(sqrt(mydata\$inflation), main ="skew(sqrt(inflation) = 0.676)")
boxplot(mydata\$gdp)
skew(mydata\$gdp)
boxplot((mydata\$gdp^2))
skew((mydata\$gdp^2))

# replot with title
boxplot(mydata\$gdp, main ="skew(gdp) = -0.965")
boxplot((mydata\$gdp^2), main = "skew(gdp^2) = 1.103")

```

2) Writing up a report

Report Template

Fri 2 Feb: Cancel

Week 6: Chapter 11 – Report and Further Issues in Time Series
Tue 6 February – Regression model with time series data

```
# import data

# assumpion cheching

# 1. nornal distribution
names(mydata)

# normality check using boxplot
boxplot(mydata\$inflation)

# normality check using skewness
install.packages("psych")
library(psych)
skew(mydata\$inflation)
boxplot(mydata\$inflation, main ="skew(inflation) = 2.167")

# data transformation

# for positive skew, we may take a sqaure root first
boxplot(sqrt(mydata\$inflation))
skew(sqrt(mydata\$inflation))
boxplot(sqrt(mydata\$inflation), main ="skew(sqrt(inflation) = 0.676)")

# sqrt(inflation) is still positively skew,
# so we can take a logarithm
boxplot(log(mydata\$inflation))

skew(log(mydata\$inflation))

par(mfrow = c(1, 2)) # set output window to be 1x2

boxplot(mydata\$inflation, main ="skew(inflation = 2.167)")

boxplot(sqrt(mydata\$inflation)
, main ="skew(sqrt(inflation) = 0.676)")
par(mfrow = c(1, 1))

boxplot(mydata\$gdp)
skew(mydata\$gdp)

boxplot((mydata\$gdp^2))
skew((mydata\$gdp^2))

# replot with title
boxplot(mydata\$gdp, # object to be plotted
main ="skew(gdp) = -0.965", # Main title
col = "blue") # colour
boxplot((mydata\$gdp^2),
main = "skew(gdp^2) = 1.103",
col = "lightblue")

###
# writing up a model result
# variables in use
# sqrt(inflation) as a dependent variable
# gdp as an explanatory/independent variable

?lm

# creat an object to store the simple regression model
model1 <- lm(inflation ~ gdp, data = mydata)

# call for regression outputs
anova(model1)
summary(model1)

# regression model with transformed data
model2 <- lm(sqrt(inflation) ~ gdp, data = mydata)
anova(model2)
summary(model2)

### gdp is not statistically significant (p < 0.05)
skew(mydata\$unemployment)
skew(sqrt(mydata\$unemployment))
skew(log(mydata\$unemployment))
par(mfrow = c(1, 3))

boxplot(mydata\$unemployment
, main = "skew(unemployment)=1.378"
, col = "red")

boxplot(sqrt(mydata\$unemployment)
, main = "skew(sqrt(unemployment)=0.675"
, col = "magenta")

boxplot(log(mydata\$unemployment)
, main = "skew(log(unemployment)=-0.101"
, col = "pink")

# regress inflation with unemployment
# untransformed variables
model3 <- lm(inflation ~ unemployment, data = mydata)
summary(model3)

model4 <- lm(inflation ~ sqrt(unemployment), data = mydata)
summary(model4)

model5 <- lm(inflation ~ log(unemployment), data = mydata)
summary(model5)

# 262 get special score (sec 004)
model6 <- lm(sqrt(inflation) ~ sqrt(unemployment), data = mydata)
summary(model6)
model7 <- lm(sqrt(inflation) ~ log(unemployment), data = mydata)
summary(model7)
##################################
# Summary
# model 6 is the best for result
# sqrt(inflation) = 2.9532 -0.6854sqrt(unemployment)
# Multiple R-squared: 0.1165
###################################

```

Fri 9 February – Cancel

Week 7: Chapter 12
Tue 13 February – Multiple Regression Model with Time Series data

```skew(mydata\$population)
skew(sqrt(mydata\$population))
par(mfrow = c(1, 1))
par(mfrow = c(1, 2))
boxplot(mydata\$population,
main = "skew(population = 0.135)",
col = "blue")
boxplot(sqrt(mydata\$population),
main = "skew(sqrt(population) = -0.132)",
col = "lightblue")
##################
# multiple regression
# model8 = model6 + sqrt(population)
model8 <- lm(sqrt(inflation) ~ sqrt(unemployment)
+ sqrt(population), data = mydata)
summary(model8)
## test model improvement
anova(model6, model8)
# post hoc check/test
plot(model6)
# plot all 4 post hoc test simultenously
par(mfrow = c(2, 2))
plot(model6)
par(mfrow = c(1, 4))
plot(model6)
plot(model8)
```

Fri 16 February: Cancellation (CMU Executive training)

Week 8: Cancellation
Tue 20 February
Fri 23 February

Week 9: Midterm exam break

Week 10: Chapter 13
Tuesday 6 March
Wednesday 7 March MIDTERM EXAM 13:00 – 16:00 hours
Friday 9March

Week 11: Chapter 14
Tuesday 13 March
Time Series Decomposition

Friday 16 March

Week 12: No class
Tuesday 20 March – No class
Friday 23 March – No cass

Week 13:
Tuesday 3 April
Friday 6 April

Week 14:
Tuesday 10 April – No class
Friday 13 April – No class

Week 15:
Tuesday 17 April – No class
Friday 20 April – No class

Week 16
Tuesday 24 April
Friday 27 April (quiz)

Time series decomposition with R

1st and 2nd May (by appointment)

Make up Tutorial (QA room)

1. May 1st, 13:00 – 17:00
2. May 2nd, 13:00 – 17:00
3. May 7th, 13:00 – 17:00
4. May 8th, 13:00 – 17:00
5. May 9th, 13:00 – 17:00

Total Make up tutorial = 20 hours

https://goo.gl/forms/sg4RYi7gRgXgi7at1

1. A >= 80
2. B+ >= 75
3. B >= 70
4. C+ >= 65
5. C >= 60
6. D+ >= 55
7. D >= 50
8. F <= 50

## Assessment

1. Midterm = 25%
2. Final = 25%
3. Two Course Projects = 40% (20 each)
4. Attention & In-class Quiz = 10%

## Exam

Midterm: 7th March 2018 13:00 – 16:00 hours

Final: 10th May 2018 15:30 – 18:30 hours

## Textbooks

• Main Text: Woodrige, J. (2012). Introductory Econometrics. 5 eds. (PDF)
• Hansen (2017). Econometrics. (PDF)

## Review of Time series Econometrics

R workshop with Rob J Hyndman’s FPP book (link) ## Assignments

1. Time Series  Data Analysis with Regression
In a group of three students, pick an economic data in world bank website and analyse using econometric tools for time series econometrics taught in the class. Submit a report of 500 words with associated outputs (numbers and graphs) –
Due date: before 12th May 2018
2. Time Series Decomposition Analysis
In a group of three students, please decompose time series components of time series economic data.  Then write a 500 words of report. In the report, there should be a section explaining the duty of each member. There should be 4 parts as follow.

1. Background of CPI data:
Explain the reason why you choose a particular product type for CPI data
2. Moving Average and calculate seasonal index
Show your excel calculation of moving average and result of seasonal index and explain the result
3. Exponential Smoothing
Show your exponential smoothing calculation in excel, chart/ plot and explain the results
4. Time series decomposition with R
Show observed and trend plot as well as the decomposition plot

Due date: before 12th May 2018

## รายงาน

1. การวิเคราะห์ข้อมูลอนุกรมเวลาด้วยแบบจำลอง Regression Time Series  Data Analysis with Regression
งานกลุ่ม 3 คนเลือกข้อมูลจาก ​World Bank database และวิเคราะห์ด้วยเครื่องมือดังนี้

1. บทนำ สาเหตุที่เลือกข้อมูลนั้น ๆ จาก World Bank data
2. Descriptive Statistics เช่น ค่าเฉลี่ย ส่วนเบี่ยงเบนมาตรฐาน
3. Data visualiation เช่น Boxplot, plot
4. Regression output
5. Regression plot
กำหนดส่ง 12 พค. 2561
2. การวิเคราะห์องค์ประกอบของข้อมูลอนุกรมเวลา
งานกลุ่ม 3 คนเลือกข้อมูล Consumer Price Index และวิเคราะห์ด้วยเครื่องมือดังนี้

1. ข้อมูลพื้นฐานของกลุ่มสินค้าที่เลือกวิเคราะห์ CPI
อธิบายสาเหตุที่เลือกกลุ่มสินค้านั้น ๆ
2. Moving Average and calculate seasonal index
แสดงผลการคำนวณและอภิปรายผล
3. Exponential Smoothing
แสดงผลการคำนวณและอภิปรายผล
4. Time series decomposition with R
แสดงผลการคำนวณและอภิปรายผล

A link to World bank data