金融时间序列分析 第3部分 Matlab时间序列分析 01
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
二.计量工具箱 Econometric toolbox
三.金融工具箱 Finance toolbox
3.1 统计工具箱 Statistics toolbox ① 单变量随机分布
② 单变量模拟抽样
③ 多变量随机分布
④ 数据拟合
单变量随机分布
>>disttool 演示各种随机分布图
t分布 与 Z分布
例子:pdf124
残差诊断
pdf 202 hist | boxplot | qqplot | ksdensity | autocorr | parcorr | lbqtest | archtest
Choose ARMA Lags Using BIC pdf 312
Ljung-Box Q-Test
ARMA Model
modelARMA = arima('AR',{0.6,-0.3},'MA',0.4);
GARCH
>>load Data_EquityIdx >>nasdaq = Dataset.NASDAQ; >>r = price2ret(nasdaq); >>r0 = r(1:2); >>rn = r(3:end); >>model1 = garch(1,1); >>fit1 = estimate(model1,rn,'E0',r0);
p207
A static conditional mean model: the ordinary linear regression model. A dynamic conditional mean model
arima class
model objects for stationary, or unit-root nonstationary linear time series models. includes
①moving average (MA), ②autoregressive (AR), ③mixed autoregressive and moving average (ARMA), ④integrated (ARIMA), ⑤multiplicative seasonal models.
Specify Conditional Mean Models Using arima
Model Objects, Properties, and Methods
Model Objects arima garch egarch gjr Model Properties Parametric form of the model Number of model parameters (e.g., the degree of the model) Innovation distribution (Gaussian or Student’s t) Amount of presample data needed to initialize the model
步骤1识别:决定模型的阶数,数据的动态特征
数据时间图,acf,pacf
步骤2估计:参数估计,OLS,极大似然估计; 步骤3检验:模型检验
过度拟合法:拟合一个更大模型,应该不显著; 残差诊断法:残差序列无线性关系,否则还有模 型没有反映出来的动态特征;(acf,pacf, Ljung-Box法)
arima(p,D,q)
(seasonal) ARIMA model p257 stationary ARMA model p283 >>MA模型
modelMA = arima('Constant',0,'MA',{0.8,0.5,-0.1}); impulse(modelMA,30) :响应值,2012a版出错
Unit Root Tests: pdf 163
Unit Root Tests: pdf 163
p122
a five-step process for identifying, selecting, and assessing conditional mean models (for discrete, univariate time series data). ARMA
-4
-3
-2
-1
0
1
2
3
4
5
重复抽样
>>randtool
%可保存随机数
%后面可用
>>z1 = random('Normal',0,1,2,4) %2行4列 x1 = 1.1650 0.0751 -0.6965 0.0591 0.6268 0.3516 1.6961 1.7971
多变量随机分布
>>mu = [2 3]; >>SIGMA = [1 1.5; 1.5 3]; %协方差矩阵 >>r = mvnrnd(mu,SIGMA,100); %随机数对 >>plot(r(:,1),r(:,2),'+')
用于检验arch效应 pdf275, pdf307
>>load Data_EquityIdx; >>Y = Dataset.NASDAQ; >>r = price2ret(Y); >>N = length(r); >>e = r - mean(r); >>figure(2) >>subplot(2,1,1) >>autocorr(e.^2) >>subplot(2,1,2) >>parcorr(e.^2) >>[h,p] = lbqtest(e.^2,'Lags',[5,10])
1. Establish the stationarity of your time series. ACF,PACF 2. Identify a (stationary) conditional mean model for your data. 3. Specify the model, and estimate the model parameters. 4. Conduct goodness-of-fit checks to ensure the model describes your data adequately. 5. use the model to forecast or generate Monte Carlo simulations
egarch
Methods
1. estimate
fit = estimate(model,Y); 返回一个model [E,V] = infer(model,Y)
2. infer
Leabharlann Baidu
residuals and conditional variances of a univariate ARIMA model fit to data Y. 3. forecast [Y,YMSE] = forecast(model,numPeriods) : responses for a univariate ARIMA model, and generates corresponding mean square errors, YMSE. 4. simulate
二、建模
1. 数据处理 data processing 2. 模型选择 model selection 3. 模拟 simulation
Data Transform
Why Transform?
Isolate temporal components of interest. Remove the effect of nuisance components (like seasonality). Make a series stationary. Reduce spurious regression effects. Stabilize variability that grows with the level of the series. Make two or more time series more directly comparable.
P136 to test for autocorrelation at multiple lags jointly
>>load Data_Overshort >>Y = Data; >>N = length(Y); >>[h,p,Qstat,crit] = lbqtest(Y,'Lags',[5,10,15]) h=1 1 1 significant autocorrelation
数据的随机拟合:单变量
dfittool
3.2 计量工具箱 Econometric toolbox
一、model
a model:对象(类似于结构变量) adequately describes your data. 基础 for:regression inference, forecasting, and Monte Carlo simulation. ① Specification tests: identify data generating process. ② Model comparisons the fit of competing models, with penalties for complexity. ③ Goodness-of-fit checks assess the in-sample adequacy, assumptions hold, out-of-sample forecast performance.
金融时间序列分析
陆贵斌
2012年10月
基本思路 作为引入,先搞清楚时间序列; 分析时间序列的目的:挖掘背后的规律, 以利于预测未来;
内容
第1部分 前言 第2部分 时间序列分析基础
第3部分 matlab时序分析
第4部分 金融时间序列分析
第3部分 Matlab时间序列分析
Matlab时间序列分析工具箱 一.统计工具箱 Statistics toolbox
[Y,E] = simulate(model,numObs) :
sample paths and residuals from the ARIMA model, model.
1)Simulate 500 data points from the ARMA(2,1) model >>simModel = arima('AR',{0.5,0.3},'MA',0.2,'Constant',0,'Variance',0.1); >> rng(5); >>Y = simulate(simModel,500); 2)Specify an ARMA(2,1) model with no constant and unknown coefficients and variance. >>model = arima(2,0,1); >>model.Constant = 0 3)Fit the ARMA(2,1) model to Y. >>fit = estimate(model,Y)
1. 趋势平稳:先回归,去掉趋势,在分析; 2. 差分平稳:确定差分的阶数(差分后平稳性); 3. 季节性平稳:差分的步数; 4. 混合平稳:滞后算子因式分解。 pdf257 pdf59 A = LagOp({1,-0.3,0.6},'Lags',[0,1,4])
趋势平稳
t = [1:200]'; trend = 0.5*t; model = arima('Constant',0,'MA',{1.4,0.8},'Variance',8); u = simulate(model,300,'numPaths',50); Yt = repmat(trend,1,50) + u(101:300,:);
也可直接用程序,呈现随机分布 >>x = -5:0.1:5; >>y = tpdf(x,5); % t 分布 >>z = normpdf(x,0,1); % 标准正态分布 >>plot(x,y,'-',x,z,'-.')
0.4 0.35 0.3 0.25 0.2 0.15 0.1 0.05 0 -5