the myth of chinese exchange rate - portland state universityweb.pdx.edu/~crkl/bde/bsts-cny.pdf ·...
TRANSCRIPT
The Myth of Chinese Exchange Rate An Application of Bayesian Structural Time Series Analysis
Kuan-Pin Lin
Professor of Economics Portland State University
Policy Changes and Events Since 2015
• 2015-08-11 中国“8.11汇改” • 2015-11-30 人民币获准“入篮” • 2015-12-11 定期公布CFETS人民币汇率指数 • 2016-06-23 英国退欧 • 2016-10-01 人民币正式“入篮” • 2016-10-29 限制购买保险 • 2016-11-03 限制比特币交易 • 2016-11-08 美国大选 • 2016-11-29 限制对外投资 • 2016-12-31 限制海外购房 • 2017-01-13央行对部分银行进行窗口指导 • 2017-02-20 中间价调整 • 2017-04-19 放宽跨境业务限制 • 2017-05-26 中间价调整 • 2017-09-11 降低购售汇成本
Time Series Analysis
• Decomposition
– Trend, Seasonal, and Error Components
• Transformation
– Log, Box-Cox, …
• Smoothing
– Exponential Smoothing
– Structural (State Space) Time Series
• Bayesian Structural Time Series Analysis
Time Series Data Analysis Using R 4
Structural Time Series Model
• Linear Gaussian State Space Model
– Measurement (Observation) Equation
– State Equations
Time Series Data Analysis Using R 5
1 1
1
1 1...
t t t t
t t t
t t t p t
a a b
b b
s s s
2
2
2
~ (0, )
~ (0, )
~ (0, )
t
t
t
N
N
N
2~ (0, )t t t t ty a s N
Structural Time Series Model
• Special Cases
– Non-Seasonal (or Local Linear Trend) Model
– Local Level Model
Time Series Data Analysis Using R 6
1 1
1
t t t
t t t t
t t t
y a
a a b
b b
2
2
2
~ (0, )
~ (0, )
~ (0, )
t
t
t
N
N
N
1
t t t
t t t
y a
a a
2
2
~ (0, )
~ (0, )
t
t
N
N
Structural Time Series Model
• Linear Gaussian State Space Model
– Matrix Representation
Time Series Data Analysis Using R 7
2
1
0 0 0
~ (0, )
~ (0, )
~ ( , )
t t t t
t t t t
y Z N
T R N V
N C P
2
2
2
0 0
, 0 0
0 0
t
t t
t
V
Time Series Data Analysis Using R 8
1 0 1 0 0
1 1 0 0 0
0 1 0 0 0
0 0 1 1 1
0 0 1 0 0
0 0 0 1 0
1 0 0
0 1 0
0 0 1
0 0 0
0 0 0
Z
T
R
1
2
Assuming 4 :
t
t
t t
t
t
p
a
b
s
s
s
Structural Time Series Model
• StrucTS – function (x, type = c("level", "trend", "BSM"),
init = NULL, fixed = NULL, optim.control =
NULL)
• Extension with Regressors
– b may be time varying as bt
– Xt may be high dimensional
Time Series Data Analysis Using R 9
2
1
0 0 0
~ (0, )
~ (0, )
~ ( , )
t t t t t
t t t t
y Z N
T R N V
N C P
b
x
Bayesian Structural Time Series Model
• Basic Bayesian Regression Model
• Variable Selection in Xb
Time Series Data Analysis Using R 10
1 1 1
1 01
0 0
1
i i
i
i i
r
i
subset of with
b b prior guess of with precission matrix
rows and columns of for which
b b b
b
b
2 2 2
2 2
( , ) ( | ) ( )
| ~ ( , ), ~ ,2 2
p p p
df ssN b
b b
b
Bayesian Structural Time Series Model
• Spike and Slab Prior Distribution
Time Series Data Analysis Using R 11
2 2 2
1 2 2 1 1
2
( , , ) ( | , ) ( | ) ( )
::
~ (1 ) | , ~ , ( )
. ., ~ ,2 2
i i
i i
i
i
p p p p
SlabSpike
N b
df sse g
b b
b
Bayesian Structural Time Series Model
• Structural Time Series Model Estimation Using Kalman Filters
• Spike and Slab Regression for Variable Selection
• Bayesian Model Averaging over the Best Models for Forecasting
Time Series Data Analysis Using R 12
Bayesian Structural Time Series Model
• Using Package bsts – function (formula, state.specification,
family = c("gaussian", "logit", "poisson",
"student"), save.state.contributions = TRUE,
save.prediction.errors = TRUE, data,
bma.method = c("SSVS", "ODA"), prior = NULL,
oda.options = list(fallback.probability = 0,
eigenvalue.fudge.factor = 0.01), contrasts =
NULL, na.action = na.pass, niter,
ping = niter/10, timeout.seconds = Inf, seed =
NULL, ...)
Time Series Data Analysis Using R 13
Bayesian Structural Time Series Model
• AddLocalLevel
– function (state.specification = NULL, y,
sigma.prior = NULL, # SdPrior
initial.state.prior = NULL, # NormalPrior
sdy,
initial.y)
Time Series Data Analysis Using R 14
Bayesian Structural Time Series Model
• AddLocalLinearTrend
– function (state.specification = NULL, y,
level.sigma.prior = NULL, # SdPrior
slope.sigma.prior = NULL, # SdPrior
initial.level.prior = NULL, # NormalPrior
initial.slope.prior = NULL, # NormalPrior
sdy, initial.y)
Time Series Data Analysis Using R 15
Bayesian Structural Time Series Model
• AddSeasonal
– function (state.specification, y, nseasons,
season.duration = 1,
sigma.prior = NULL, # SdPrior
initial.state.prior = NULL, # NormalPrior
sdy)
Time Series Data Analysis Using R 16
Bayesian Structural Time Series Model
• SdPrior
– function (sigma.guess, sample.size = 0.01,
initial.value = sigma.guess, fixed = FALSE,
upper.limit = Inf)
• This sets a gamma prior on 1/σ2. Shape (α) = sigma.guess2 ×sample.size/2 Scale (β) = sample.size/2 If specify an upper limit on σ then support will be truncated.
• NormalPrior
– function (mu, sigma, initial.value = mu, fixed
= FALSE)
Time Series Data Analysis Using R 17
BSTS Application
• Counterfactual Inference
– Estimating the causal effect of a designed intervention on a time series: How the response variable would have evolved after the intervention if the intervention had never occurred?
– Random experiments method vs. non-random experimental approach.
18 Time Series Data Analysis Using R
BSTS Application
• Assumptions on Counterfactual Inference
– There is a set of control time series that were themselves not effected by the intervention.
– The relationship between covariates and treated time series, as established during the pre-intervention period, remains stable throughout the post-intervention period.
19 Time Series Data Analysis Using R
BSTS Application
• Bayesian Counterfactual Inference
– A Bayesian structural time series model is used to estimate and predict the counterfactual.
– Priors are part of the model.
– Given a response time series model, performs posterior inference on the counterfactual by computing estimates of the causal effect.
20 Time Series Data Analysis Using R
BSTS Application
• CausalImpact – function (data = NULL,
pre.period = NULL,
post.period = NULL,
model.args = NULL,
bsts.model = NULL,
post.period.response = NULL,
alpha = 0.05)
21 Time Series Data Analysis Using R
BSTS Application
• References
– CausalImpact 1.2.1
– Inferring Causal Impact Using Bayesian Structural Time Series Models
22 Time Series Data Analysis Using R