当前位置:
文档之家› 金融时间序列分析 第3部分 Matlab时间序列分析 01
金融时间序列分析 第3部分 Matlab时间序列分析 01
egarch
Methods
1. estimate
fit = estimate(model,Y); 返回一个model [E,V] = infer(model,Y)
2. infer
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
①moving average (MA), ②autoregressive (AR), ③mixed autoregressive and moving average (ARMA), ④integrated (ARIMA), ⑤multiplicative seasonal models.
Specify Conditional Mean Models Using arima
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
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,:);
例子:pdf124oxplot | qqplot | ksdensity | autocorr | parcorr | lbqtest | archtest
Choose ARMA Lags Using BIC pdf 312
Ljung-Box Q-Test
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
金融时间序列分析
陆贵斌
2012年10月
基本思路 作为引入,先搞清楚时间序列; 分析时间序列的目的:挖掘背后的规律, 以利于预测未来;
内容
第1部分 前言 第2部分 时间序列分析基础
第3部分 matlab时序分析
第4部分 金融时间序列分析
第3部分 Matlab时间序列分析
Matlab时间序列分析工具箱 一.统计工具箱 Statistics toolbox
二.计量工具箱 Econometric toolbox
三.金融工具箱 Finance toolbox
3.1 统计工具箱 Statistics toolbox ① 单变量随机分布
② 单变量模拟抽样
③ 多变量随机分布
④ 数据拟合
单变量随机分布
>>disttool 演示各种随机分布图
t分布 与 Z分布
也可直接用程序,呈现随机分布 >>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
-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),'+')
数据的随机拟合:单变量
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.
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
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
[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)
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版出错
步骤1识别:决定模型的阶数,数据的动态特征
数据时间图,acf,pacf
步骤2估计:参数估计,OLS,极大似然估计; 步骤3检验:模型检验
过度拟合法:拟合一个更大模型,应该不显著; 残差诊断法:残差序列无线性关系,否则还有模 型没有反映出来的动态特征;(acf,pacf, Ljung-Box法)