2018/09/24

Fundamental Question First: Why do I attend (teach) this course?

  • Credits

  • Better understandings of the economic world

  • And most importantly, your curiosities about the unknowns.

Credits

  • Final exam (14 points): 50% on implementation, 50% on theory. Last year exam available on moodle. Quite easy.

  • Two take-home exercises using R (3 points each): Empirical questions. To be published at the end of Oct and end of Nov.

  • Slides available on moodle https://moodleucl.uclouvain.be/ under the name LECON2031

  • Lectures: Theory and general ideas. Some discussions about implementations.

  • Tutorials: user-oriented (how to solve take-home exercises).

Understandings of economies

  • How do we (or I) see the economic world nowadays?

Understandings of economies

Problem 1. Projections may be misleading

Problem 2. Variables may be improperly measured

Problem 3. Their changes are caused by other hidden unmeasruable factors

Problem 4. Predictions are Alchemy type games.

If all these are untrustworthy, what do you believe? No answer to this question. (Perhaps yourself?)

Better(?) understandings of economies

  • In order to better understand the game, we only investigate part of the game, the part that can be examined by ourselves…
  • Namely, those measurable variables themselves, excluding the hidden unmeasurable factors.

Better(?) understandings of economies

Be interested in the values of the same variables with respect to time: Time series

What is time series?

  • Time series: a sequence of observations over time.

  • Time series is to describe the dynamical features.

  • The growth of information over time.

Your (My) curiosities

  • Do we solve the untrustworthy problem by looking at time series?

  • No, the problem roots in the deeper layer (in the flow chart it should be the topmost layer).

  • Other existing ways cannot tackle it either.

Your (My) curiosities

But time (and space) is the very few available element that can lift lower dimensional creatures (as human beings) to view their world with the angle from higher dimensions.

Your curiosities

  • The course will equip you with a device using time dimension.

  • You may still get stuck in this low dimensional observable world.

  • But at least, you will have an equipment for your further exploration.

  • The curiosities persist our possibility of leaping into a higher dimension.

Course Outline

1. Time Series Data and Programming 6. Non-stationarity and Integrated process
2. Stationarity 7. Filters and Seasonality
3. Moving Average Model (MA) 8. System Identification
4. Auto-Regressive Model (AR) 9. Vector AR
5. ARMA Modeling 10. VAR Modeling
11. Kalman Filter

References

Reference:

  • Introductory Time Series with R
  • Time Series Analysis and Its Applications: With R Examples

Advanced Reference:

  • Time Series Analysis: Forecasting and Control 5th Edition

R

Your First Time Series Program

x = rep(0,20)
x
##  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
x[1] = 0; x[2] = 1
for(t in 3:20){x[t] = x[t-1] + x[t-2]}
x
##  [1]    0    1    1    2    3    5    8   13   21   34   55   89  144  233
## [15]  377  610  987 1597 2584 4181

Your First Time Series Program

plot(x)

Time Series and Iterative Schemes

  • Current computer programming heavily depends on iterations.

  • For example, the previous for loop iteration

for(t in 3:20){x[t] = x[t-1] + x[t-2]}

fulfills the Fibonacci sequence \[ x_t = x_{t-1} + x_{t-2}\] from \(x_1=0, x_2=1\) to \(x_{20} = 4181\). Here, time index is the number of iterations.

Data and Matrix

  • Data information is stored as a matrix. In R, a vector can be numerical
a = c(90,60,50,55,20,40) 
  • and can be characteristic
b = c("A","B","C","C","C","C")
  • or even be logical (0=FALSE, 1=TRUE)
c = c(TRUE,TRUE,FALSE,FALSE,FALSE,FALSE) 
as.numeric(c)
## [1] 1 1 0 0 0 0

Data and Matrix

mydata = data.frame(a,b,c)
names(mydata) = c("Score","Level","Passed") 
mydata
##   Score Level Passed
## 1    90     A   TRUE
## 2    60     B   TRUE
## 3    50     C  FALSE
## 4    55     C  FALSE
## 5    20     C  FALSE
## 6    40     C  FALSE
mydata$Score
## [1] 90 60 50 55 20 40

Data and Matrix

as.matrix(mydata)
##      Score Level Passed 
## [1,] "90"  "A"   " TRUE"
## [2,] "60"  "B"   " TRUE"
## [3,] "50"  "C"   "FALSE"
## [4,] "55"  "C"   "FALSE"
## [5,] "20"  "C"   "FALSE"
## [6,] "40"  "C"   "FALSE"
matdata = as.matrix(mydata)
matdata[1,1]
## Score 
##  "90"

The Observable World

The Observable World

library(Quandl)
BE_GDP = Quandl("WWDI/BEL_NY_GDP_PCAP_KN") 
tail(BE_GDP, n = 2)
FALSE          Date     Value
FALSE 57 1961-12-31 10422.791
FALSE 58 1960-12-31  9961.546
colnames(BE_GDP)=c("Time", "GDP per Capita")
tail(BE_GDP, n = 2)
FALSE          Time GDP per Capita
FALSE 57 1961-12-31      10422.791
FALSE 58 1960-12-31       9961.546

The Observable World

plot(BE_GDP)

The Observable World: a better look

BE_GDP_new = Quandl("WWDI/BEL_NY_GDP_PCAP_KN", type="xts") 
library(dygraphs); dygraphs::dygraph(BE_GDP_new, main = "GDP Per Capita")

The Simulated World

set.seed(2018)
e = rnorm(250)
plot(e); abline(h=0)

The Simulated World

y = rep(0,250); 
for(t in 1:250){y[t+1]=y[t]+e[t]}
plot(y); abline(h=0)

A Taste of Fake Randomness

  • The previous picture looks quite realistic.

  • But in fact, it is a seemingly random time series.

  • It is simulated by some iterative scheme which is completely deterministic.

  • Proof: If you copy the code and run in your computer, you will get the same exact pattern. It violates the principle of randomness.

  • “Anyone who attempts to generate random numbers by deterministic means is, of course, living in a state of sin.” John von Neumann

A Taste of Fake Randomness

N = rep(0,250); U = rep(0,250); U[1] = 100 # the seed
for(t in 2:250){  
    U[t] = (1664525 * U[t-1] + 1013904223) %% 2^32
    N[t] = sqrt(2*log(U[t]))*sin(2*pi*U[t])}
hist(N)

Summary

  • The Motivation of this course.

  • The way of understanding the current situation: time and information.