金融时间序列分析 第3部分 Matlab时间序列分析.ppt_第1页
金融时间序列分析 第3部分 Matlab时间序列分析.ppt_第2页
金融时间序列分析 第3部分 Matlab时间序列分析.ppt_第3页
金融时间序列分析 第3部分 Matlab时间序列分析.ppt_第4页
金融时间序列分析 第3部分 Matlab时间序列分析.ppt_第5页
免费预览已结束,剩余87页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

金融时间序列分析,陆贵斌2012年10月,基本思路,作为引入,先搞清楚时间序列;分析时间序列的目的:挖掘背后的规律,以利于预测未来;,内容,第3部分Matlab时间序列分析,Matlab时间序列分析工具箱,统计工具箱Statisticstoolbox计量工具箱Econometrictoolbox金融工具箱Financetoolbox,3.1统计工具箱Statisticstoolbox,单变量随机分布单变量模拟抽样多变量随机分布Copulas模拟(暂时不讲)回归分析,单变量随机分布,disttool演示各种随机分布图,t分布与Z分布,也可直接用程序,呈现随机分布x=-5:0.1:5;y=tpdf(x,5);%t分布z=normpdf(x,0,1);%标准正态分布plot(x,y,-,x,z,-.),重复抽样,randtool%可保存随机数%后面可用,z1=random(Normal,0,1,2,4)%2行4列x1=1.16500.0751-0.69650.05910.62680.35161.69611.7971,多变量随机分布,mu=23;SIGMA=11.5;1.53;%协方差矩阵r=mvnrnd(mu,SIGMA,100);%随机数对plot(r(:,1),r(:,2),+),数据的随机拟合:单变量,dfittool,多变量随机数模拟,MU=12;-3-5;SIGMA=cat(3,20;0.5,10;01);p=ones(1,2)/2;obj=gmdistribution(MU,SIGMA,p);Y=random(obj,1000);scatter(Y(:,1),Y(:,2),10,.),Copulas模拟,Copulas函数:描述多变量间相关性;描述边际分布。对于非标准多元随机分布,一大难题:相互依赖性如,MonteCarlo模拟相关性可能都需要从实际数据中获取。,rho=.7;SigmaDep=sigma.2.*1rho;rho1ZDep=mvnrnd(00,SigmaDep,n);XDep=exp(ZDep);lot(XDep(:,1),XDep(:,2),.)axis(0505)axisequalxlabel(X1)ylabel(X2),传统模型,用多元正态、Gamma、极值分布来描述缺点:边际分布都是同一族类的,n=1000;z=normrnd(0,1,n,1);hist(z,-3.75:.5:3.75),Copulas的目标,生产多元分布,存在相互依赖;通过一定的转变方法,将各自的分布、及依赖结构分离出来。Z:标准正态分布;:Z的分布函数U:Unif(0,1)分布,u=normcdf(z);hist(u,.05:.1:.95),Copulas核心,将F分布的逆分布函数应用于(0,1)均匀随机变量上,仍然是F随机分布。,可以将它转变为gamma(2,1)分布,x=gaminv(u,2,1);hist(x,.25:.5:9.75),n=1000;rho=.7;Z=mvnrnd(00,1rho;rho1,n);U=normcdf(Z);X=gaminv(U(:,1),2,1)tinv(U(:,2),5);scatterhist(X(:,1),X(:,2),Direction,out),Copulas重要理解,Sklar(1959)定理:对于多元分布H,F、G为边际分布,则C函数存在,且唯一。C(u,v),u=F(x),v=G(y)u,v:(0,1)2,C:(0,1)FarlieGumbelMorgensternfamilycopulas,若X,Y相互独立,则C=uv若Y是X的确定函数,则FrchetHoeffdingbounds递减型:W(u,v)=max(0,u+v1)递增型:M(u,v)=min(u,v)W(u,v)C(u,v)M(u,v),转换transform,twoincreasingtransformations,为了描述这种一致性,引入rankpairs(R*,S*)经验copulas,Deheuvels(1979)可以证明:Cn是C的无偏估计量,服从正态分布。,Copulas研究现状,copulas模型的推断统计仍有待深入;面向终端用户的应用太少,不够直观;金融方面:FreesandValdez1998;Cherubinietal.2004,StatisticsToolboxfunctionscompute,Probabilitydensityfunctions(copulapdf),thecumulativedistributionfunctions(copulacdf)forGaussiancopulasRankcorrelationsfromlinearcorrelations(copulastat)andviceversa(copulaparam)Randomvectors(copularnd)Parametersforcopulasfittodata(copulafit),ProbabilityDistributionsUsedforMultivariateModeling,Copulas:GenerateCorrelatedSamplesDeterminingDependenceBetweenSimulationInputsConstructingDependentBivariateDistributionsUsingRankCorrelationCoefficientsUsingBivariateCopulasHigherDimensionCopulasArchimedeanCopulasSimulatingDependentMultivariateDataUsingCopulasExample:FittingCopulastoData,回归分析,robustdemo,3.2计量工具箱Econometrictoolbox,amodel:面向对象(类似于结构变量),modelselection,amodel:adequatelydescribesyourdata.基础for:regressioninference,forecasting,andMonteCarlosimulation.Specificationtests:identifydatageneratingprocess.Modelcomparisonsthefitofcompetingmodels,withpenaltiesforcomplexity.Goodness-of-fitchecksassessthein-sampleadequacy,assumptionshold,out-of-sampleforecastperformance.,ModelObjects,Properties,andMethods,ModelObjectsarimagarchegarchgjrModelPropertiesParametricformofthemodelNumberofmodelparameters(e.g.,thedegreeofthemodel)Innovationdistribution(GaussianorStudentst)Amountofpresampledataneededtoinitializethemodel,Astaticconditionalmeanmodel:theordinarylinearregressionmodel.Adynamicconditionalmeanmodel,p207,arimaclass,modelobjectsforstationary,orunit-rootnonstationarylineartimeseriesmodels.includesmovingaverage(MA),autoregressive(AR),mixedautoregressiveandmovingaverage(ARMA),integrated(ARIMA),multiplicativeseasonalmodels.,SpecifyConditionalMeanModelsUsingarima,arima(p,D,q),(seasonal)ARIMAmodelp257stationaryARMAmodelp283MA模型modelMA=arima(Constant,0,MA,0.8,0.5,-0.1);impulse(modelMA,30):响应值,2012a版出错,ARMAModel,modelARMA=arima(AR,0.6,-0.3,MA,0.4);,Methods,estimate:EstimateARIMAmodelparametersinfer:InferGJRmodelconditionalvariancesforecastsimulate,1)Simulate500datapointsfromtheARMA(2,1)modelsimModel=arima(AR,0.5,-0.3,MA,0.2,Constant,0,Variance,0.1);rng(5);Y=simulate(simModel,500);2)SpecifyanARMA(2,1)modelwithnoconstantandunknowncoefficientsandvariance.model=arima(2,0,1);model.Constant=03)FittheARMA(2,1)modeltoY.fit=estimate(model,Y),DataTransform,WhyTransform?Isolatetemporalcomponentsofinterest.Removetheeffectofnuisancecomponents(likeseasonality).Makeaseriesstationary.Reducespuriousregressioneffects.Stabilizevariabilitythatgrowswiththeleveloftheseries.Maketwoormoretimeseriesmoredirectlycomparable.,p122,afive-stepprocessforidentifying,selecting,andassessingconditionalmeanmodels(fordiscrete,univariatetimeseriesdata).ARMAEstablishthestationarityofyourtimeseries.ACF,PACFIdentifya(stationary)conditionalmeanmodelforyourdata.Specifythemodel,andestimatethemodelparameters.Conductgoodness-of-fitcheckstoensurethemodeldescribesyourdataadequately.usethemodeltoforecastorgenerateMonteCarlosimulations,步骤1识别:决定模型的阶数,数据的动态特征数据时间图,acf,pacf步骤2估计:参数估计,OLS,极大似然估计;步骤3检验:模型检验过度拟合法:拟合一个更大模型,应该不显著;残差诊断法:残差序列无线性关系,否则还有模型没有反映出来的动态特征;(acf,pacf,Ljung-Box法),ARMA模型选择的信息法则,一开始实际数据比较杂乱,acf和pacf的规律不会非常简单、直观;难以选择模型;信息准则包含:残差平方和的函数;由于增加额外参数所丧失的自由度的惩罚项;增加一个新变量:残差平方和减少惩罚项增加目标:使信息准则的值最小。,最常用的信息准则,赤池AIC更具有有效性阶数较大Schwarz贝叶斯准则SBIC较强一致性渐进递归到正确的模型阶数平均波动性较大Hannan-Quinn准则HQIC没有一种准则明显有优势,各有特点。,画出ACF,PACF,loadData_JAustralianY=Dataset.PAU;N=length(Y);figure(1)plot(Y)figure(2)subplot(2,1,1)autocorr(Y)subplot(2,1,2)parcorr(Y),Differencethedata.,ACF线性递减,显著:非平稳dY=diff(Y);差分后序列ACF快速衰减,PACF2阶截断;表现与AR(2)类似;SpecifyandfitanARIMA(2,1,0)model.model=arima(2,1,0);fit=estimate(model,Y);coefficientsaresignificantatthe0.05significancelevel,Infertheresidualsfromthefittedmodel.Checkthattheresidualsarenormallydistributedanduncorrelated.res=infer(fit,Y);plot(res./sqrt(fit.Variance)qqplot(res):正态分布对比autocorr(res)parcorr(res),Generateforecastsandapproximate95%forecastintervalsYf,YMSE=forecast(fit,16,Y0,Y);UB=Yf+1.96*sqrt(YMSE);LB=Yf-1.96*sqrt(YMSE);h1=plot(Y,Color,.75,.75,.75);holdonh2=plot(78:93,Yf,r,LineWidth,2);h3=plot(78:93,UB,k-,LineWidth,1.5);plot(78:93,LB,k-,LineWidth,1.5);,Ljung-BoxQ-Test,P136totestforautocorrelationatmultiplelagsjointlyloadData_OvershortY=Data;N=length(Y);h,p,Qstat,crit=lbqtest(Y,Lags,5,10,15)h=111significantautocorrelation,用于检验arch效应,loadData_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),MaximumLikelihoodEstimationforConditionalMeanModelsp292EstimateConditionalMeanandVarianceModelp307,SpecifyingStaticTimeSeriesModels,Demo_StaticModels.mSpecifyingStaticTimeSeriesModels.pdf,Box-JenkinsDifferencingvs.ARIMAEstimation,p288,generateMsamplepaths,eachoflengthNMarkovChainMonteCarlo(MCMC)generatedependentrandomdraws;ThesimulatemethodinEconometricsToolboxgeneratesindependentrealizations.DemonstratingtheoreticalresultsForecastingfutureeventsEstimatingtheprobabilityoffutureevents,Step1.Specifyamodel.model=arima(Constant,0.5,AR,0.7,0.25,Variance,.1);Step2.Generateonesamplepathrng(default):控制随机数生成模式Y=simulate(model,50);Step3.Generatemanysamplepaths.Y=simulate(model,50,numPaths,1000);Step4.Oversampletheprocess.Toreducetransienteffects,(短暂的)simulatepathsoflength150,anddiscardthefirst100observations.,TransientEffects,stationaryprocessestheimpulseresponsefunctiondecaystozeroovertime.thestartingpointofthesimulationiseventuallyforgotten.Oversample:generatesamplepathslongerthanneeded,anddiscardthebeginningsamplesthatshowtransienteffects.Recycle:useafirstsimulationtogeneratepresampledataforasecondsimulation.nonstationaryprocessesthestartingpointofthesimulationisneverforgotten.default:beginwith0;specifyyourownpresampledata.,没有自相关性,但是,有相关性,称为“seriallydependent”,金融条件方差模型特征,波动聚集Volatilityclustering原因:波动率的自相关性杠杆效应Leverageeffects非对称性效应:波动率对大幅下跌的反应强于大幅上升(EGARCH,GJR),多元时间序列分析,3.3金融工具箱Financetoolbox,HotTip,HowdoIincorporatemylogotoaslidethatwillapplytoalltheotherslides?OntheViewmenu,pointtoMaster,andthenclickSlideMasterorNotesMaster.Changeimagestotheoneyoulike,thenitwillapplytoalltheotherslides.,Youcanbrieflyaddoutlineofthisslidepageinthistextbox.,Diagram,Youcanbrieflyaddoutlineofthisslidepageinthistextbox.,Diagram,Youcanbrieflyaddoutlineofthisslidepageinthistextbox.,CycleDiagram,Youcanbrieflyaddoutlineofthisslidepageinthistextbox.,Diagram,Youcanbrieflyaddoutlineofthisslidepag

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论