版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Taobao大数据部落数据处理思路#1.原始数据为4组时间序列;#读取软件包library("fGarch")library("quantmod")library(ghyp)library(copula)#设置工作目录##读取数据data=read.csv("Data.csv")head(data)# Pound Jpan Usd Eur#1 -0.016689192 -0.006422036 -0.004161304 0.001084608#2 0.000000000 0.005993930 0.000000000 -0.034008741#3 0.000000000 -0.006850273 0.008322209 -0.013969242#4 0.012517495 0.010275005 0.000000000 -0.001120290#5 0.012513888 -0.007277877 0.020798548 -0.011676878#6 -0.008342191 0.002140679 0.012474350 0.007202157data=na.omit(data)2.对每组数据进行基本检验(自回归,异方差,自相关,稳定性,正态性)然后进行ARCH(1,1)建模,得到四个边缘分布;#自编函数进行基本检验testfun=function(yield){#绘制时序图ts.plot(yield)#基本统计量summary(yield)sd(yield)var(yield)# /*偏度、峰度*/n<-length(yield)m<-mean(yield)s<-sd(yield)g1<-n/((n-1)*(n-2))*sum((yield-m)八3)/s八3g2<-((n*(n+1))/((n-1)*(n-2)*(n-3))*sum((yield-m)八4)/s八4-(3*(n-1)八2)/
Taobao大数据部落((n-2)*(n-3)))#偏度g1#峰度g2# /*作图*/hist(yield,freq=F)lines(density(yield))#QQ图(正态性)qqnorm(yield)qqline(yield)library(tseries)# /*JB检验*/(检验正态性)print(jarque.bera.test(yield))# /*自相关性检验*/print(Box.test(yield,type="Ljung-Box"))然后用自相关图检查序列的平稳性,,最后发现一阶差分后的序列是平稳的#检验自相关偏相关系数acf(yield)pacf(yield)下面对平稳性序列建立模型,偏相关系数在滞后!期后很快地趋向于0,所以取p=1,自相关系数图形具有拖尾性,所以初步判断诲(1)模型# /*单位根检验*/稳定性检验print(adf.test(yield))print(pp.test(yield))# /*ARCH-LM检验结果*/异方差检验library(FinTS)print(ArchTest(yield,lags=12,demean=FALSE))# 建立/*GARCH*/模型library(fGarch);library(rugarch)#/*GARCH(1,1)-norm*/garch_norm<-garchFit(yield〜garch(1,1),trace=FALSE)garch_normspec<-ugarchspec(variance.model=list(garchOrder=c(1,1)),mean.model=list(armaOrder=c(0,0)))fit<-ugarchfit(spec=spec,data=yield)
Taobao大数据部落fit#对每一组数据进行分析yield=data[,1]testfun(yield)Taobao大数据部落TimeHistogramofyieldId
lle[Taobao大数据部落NormalQ-QPloto । ।iiiir-3-2-10 1 2 3TheoreticalQuantiles##JarqueBeraTest##data:yield#X-squared=614.62,df=2,p-value<2.2e-16###Box-Ljungtest##data:yield#X-squared=0.51149,df=1,p-value=0.4745
Taobao大数据部落Seriesyield#Warninginadf.test(yield):p-valuesmallerthanprintedp-value##AugmentedDickey-FullerTest##data:yield#Dickey-Fuller=-13.844,Lagorder=13,p-value=0.01#alternativehypothesis:stationary#Warninginpp.test(yield):p-valuesmallerthanprintedp-value##Phillips-PerronUnitRootTest##data:yield#Dickey-FullerZ(alpha)=-2511.3,Truncationlagparameter=9,#p-value=0.01#alternativehypothesis:stationary###ARCHLM-test;Nullhypothesis:noARCHeffects##data:yield#Chi-squared=137.66,df=12,p-value<2.2e-16#Loadingrequiredpackage:parallel
Taobao大数据部落##Attachingpackage:'rugarch'#Thefollowingobjectismaskedfrom'package:stats':##sigmaSeriesyieldTOC\o"1-5"\h\zS/ । .o0 5 10 15 20 25 30 35Lag##* *#* GARCHModelFit *#* *##ConditionalVarianceDynamics# #GARCHModel:sGARCH(1,1)#MeanModel:ARFIMA(0,0,0)#Distribution:norm##OptimalParameters# ##EstimateStd.ErrortvaluePr(>|t|)##mu-0.0003060.000404-0.75660.44929##omega0.0000050.0000041.30700.19123##alpha10.0269570.0050415.34780.00000##beta10.9639890.002210436.18680.00000####RobustStandardErrors:Taobao大数据部落####mu##omega################alpha1beta1Estimate-0.0003060.0000050.0269570.963989Std.Error0.0004300.0000250.0312150.005525tvalue-0.711640.189450.86359174.47964Pr(>|t|)0.476690.849740.387820.00000LogLikelihood:####mu##omega################alpha1beta1Estimate-0.0003060.0000050.0269570.963989Std.Error0.0004300.0000250.0312150.005525tvalue-0.711640.189450.86359174.47964Pr(>|t|)0.476690.849740.387820.00000LogLikelihood:6477.686InformationCriteria##Akaike##Bayes##Shibata-4.8275-4.8187-4.8275##Hannan-Quinn-4.8243####WeightedLjung-BoxTestonStandardizedResiduals################statisticLag[1] 0.00832Lag[2*(p+q)+(p+q)-1][2] 1.48204Lag[4*(p+q)+(p+q)-1][5] 4.83395d.o.f=0H0:Noserialcorrelationp-value0.92730.36520.1668##WeightedLjung-BoxTestonStandardizedSquaredResiduals##############Lag[1]Lag[2*(p+q)+(p+q)-1][5]Lag[4*(p+q)+(p+q)-1][9]d.o.f=2statistic6.928.1111.59p-value0.0085220.0276720.022506##WeightedARCHLMTests## ####ARCH##ARCH##ARCHLag[3]Lag[5]Lag[7]Statistic0.29372.03345.6010Shape0.5001.4402.315Scale2.0001.6671.543## ####ARCH##ARCH##ARCHLag[3]Lag[5]Lag[7]Statistic0.29372.03345.6010Shape0.5001.4402.315Scale2.0001.6671.543P-Value0.58780.46390.1704##########NyblomstabilitytestJointStatistic:4.4761IndividualStatistics:##mu##omega##alpha1##beta1##0.320130.760210.091710.23634##AsymptoticCriticalValues(10%5%1%)Taobao大数据部落##JointStatistic: 1.071.241.6##IndividualStatistic: 0.350.470.75####SignBiasTest## ##t-valueprobsig##SignBias2.02860.04260**##NegativeSignBias2.53880.01118**##PositiveSignBias0.29350.76914##JointEffect6.99890.07193*######AdjustedPearsonGoodness-of-FitTest:## ##groupstatisticp-value(g-1)##120105.74.951e-14##230216.21.590e-30##340284.35.053e-39##450404.91.711e-57######Elapsedtime:0.784045yield=data[,2]testfun(yield)Taobao大数据部落HistogramofyieldId
lle[Taobao大数据部落NormalQ-QPlot-3-2-10 1 2 3TheoreticalQuantiles###JarqueBeraTest##data:yield#X-squared=622.46,df=2,p-value<2.2e-16###Box-Ljungtest##data:yield#X-squared=8.6698,df=1,p-value=0.003235
Taobao大数据部落Seriesyield#Warninginadf.test(yield):p-valuesmallerthanprintedp-value##AugmentedDickey-FullerTest##data:yield#Dickey-Fuller=-13.404,Lagorder=13,p-value=0.01#alternativehypothesis:stationary#Warninginpp.test(yield):p-valuesmallerthanprintedp-value
Taobao大数据部落##Phillips-PerronUnitRootTest##data:yield#Dickey-FullerZ(alpha)=-2799.7,Truncationlagparameter=9,#p-value=0.01#alternativehypothesis:stationary###ARCHLM-test;Nullhypothesis:noARCHeffects##data:yield#Chi-squared=200.84,df=12,p-value<2.2e-16#TOC\o"1-5"\h\z#* *#* GARCHModelFit *#* *##ConditionalVarianceDynamics# #GARCHModel:sGARCH(1,1)#MeanModel:ARFIMA(0,0,0)#Distribution:norm###OptimalParameters##
Taobao大数据部落## EstimateStd.ErrortvaluePr(>|t|)##mu -0.000378 0.000162-2.326060.020015##omega##alpha1##beta1##omega##alpha1##beta10.0000010.0734540.9184890.0541461.356590.174911##Robust####mu##omega##alpha1##beta1StandardErrors:EstimateStd.Error##Robust####mu##omega##alpha1##beta1StandardErrors:EstimateStd.Error-0.0003780.0000010.0734540.9184890.0045510.0002243.6091323.598937tvalue-0.0830400.0044030.0203520.255211Pr(>|t|)0.933820.996490.983760.79856####LogLikelihood:8875.036###InformationCriteria## ###Akaike -6.6152#Bayes -6.6064#Shibata -6.6152##Hannan-Quinn-6.6121####WeightedLjung-BoxTestonStandardizedResiduals## # statistic p-value#Lag[1] 1.670 0.1963#Lag[2*(p+q)+(p+q)-1][2] 2.129 0.2422#Lag[4*(p+q)+(p+q)-1][5] 3.179 0.3754#d.o.f=0#H0:Noserialcorrelation###WeightedLjung-BoxTestonStandardizedSquaredResiduals##############Lag[1]Lag[2*(p+q)+(p+q)-1][5]Lag[4*(p+q)+(p+q)-1][9]d.o.f=2statistic1.3651.7812.051p-value0.24270.67110.8988#####ARCHLag[3]#ARCHLag[5]#ARCHLag[7]###WeightedARCHLMTests## StatisticShapeScaleP-Value0.59470.5002.0000.44060.71501.4401.6670.81890.81942.3151.5430.9411##Nyblomstabilitytest## ##JointStatistic:83.8698Taobao大数据部落#IndividualStatistics:#mu0.1258#omega8.1451#alpha10.1628#beta10.2932##AsymptoticCriticalValues(10%5%1%)#JointStatistic: 1.071.241.6#IndividualStatistic: 0.350.470.75##SignBiasTest# # t-value prob sig#SignBias 0.8300 0.4066#NegativeSignBias0.00960.9923#PositiveSignBias0.85000.3954#JointEffect 3.9034 0.2721###AdjustedPearsonGoodness-of-FitTest:# ##groupstatisticp-value(g-1)##120134.12.473e-19##230178.12.286e-23##340156.35.577e-16##450207.42.232e-21###Elapsedtime:0.686039yield=data[,3]testfun(yield)Taobao大数据部落QOc5I0 500WOO150{) 2000 2500TimeHistogramofyieldId
lle[Taobao大数据部落NormalQ-QPlotGBquBn。NormalQ-QPlotGBquBn。8-dEmto-3-2-10 1 2 3TheoreticalQuantiles###JarqueBeraTest##data:yield#X-squared=1139.4,df=2,p-value<2.2e-16###Box-Ljungtest##data:yield#X-squared=1.7147,df=1,p-value=0.1904Taobao大数据部落Seriesyield0 5 10 152D25 30 35Lag#Warninginadf.test(yield):p-valuesmallerthanprintedp-value##AugmentedDickey-FullerTest##data:yield#Dickey-Fuller=-13.046,Lagorder=13,p-value=0.01#alternativehypothesis:stationary#Warninginpp.test(yield):p-valuesmallerthanprintedp-valueTaobao大数据部落0 5 10 15 20 25 30 35Lag##Phillips-PerronUnitRootTest##data:yield#Dickey-FullerZ(alpha)=-2592.1,Truncationlagparameter=9,#p-value=0.01#alternativehypothesis:stationary###ARCHLM-test;Nullhypothesis:noARCHeffects##data:yield#Chi-squared=186.82,df=12,p-value<2.2e-16#TOC\o"1-5"\h\z#* *#* GARCHModelFit *#* *##ConditionalVarianceDynamics# #GARCHModel:sGARCH(1,1)#MeanModel:ARFIMA(0,0,0)#Distribution:norm###OptimalParameters##
Taobao大数据部落## EstimateStd.ErrortvaluePr(>|t|)##mu -0.000280 0.000409-0.685010.493340##omega##alpha1##beta1##omega##alpha1##beta10.0000030.0407330.9537840.004312 9.44690 0.0000000.004676203.976870.000000##StandardErrors:EstimateStandardErrors:EstimatePr(>|t|)0.474770.351070.000000.00000##Robust####mu##omega##alpha1##beta1-0.0002800.0000030.0407330.953784Std.Error0.0003920.0000040.0049570.006562tvalue-0.714740.932518.21679145.34066####LogLikelihood:6305.272####InformationCriteria## ###Akaike -4.6989#Bayes -4.6901#Shibata -4.6989##Hannan-Quinn-4.6958####WeightedLjung-BoxTestonStandardizedResiduals## # statistic p-value#Lag[1] 1.487 0.2227#Lag[2*(p+q)+(p+q)-1][2] 2.793 0.1596#Lag[4*(p+q)+(p+q)-1][5] 4.167 0.2340#d.o.f=0#H0:NoserialcorrelationStandardizedSquaredResiduals#StandardizedSquaredResiduals##statisticp-value##Lag[1] 0.22180.6377##Lag[2*(p+q)+(p+q)-1][5] 0.62450.9369##Lag[4*(p+q)+(p+q)-1][9] 1.21580.9755##WeightedLjung-BoxTeston## ##d.o.f=2####WeightedARCHLMTests## # Statistic Shape Scale P-Value#ARCH Lag[3] 0.003795 0.500 2.000 0.9509#ARCH Lag[5] 0.558535 1.440 1.667 0.8662#ARCH Lag[7] 0.860015 2.315 1.543 0.9352##Nyblomstabilitytest# #JointStatistic:11.858Taobao大数据部落#IndividualStatistics:#mu0.04612#omega1.68786#alpha10.21234#beta10.13921##AsymptoticCriticalValues(10%5%1%)#JointStatistic: 1.071.241.6#IndividualStatistic: 0.350.470.75##SignBiasTest# # t-value prob sig#SignBias 0.50882 0.6109#NegativeSignBias0.029040.9768#PositiveSignBias0.956150.3391#JointEffect3.239740.3561###AdjustedPearsonGoodness-of-FitTest:# ##groupstatisticp-value(g-1)##120224.44.516e-37##230414.97.179e-70##340530.31.819e-87##450669.57.785e-110###Elapsedtime:0.5700321yield=data[,4]testfun(yield)Taobao大数据部落TimeHistogramofyieldTaobao大数据部落NormalQ-QPlot-3-2-10 1 2 3TheoreticalQuantiles###JarqueBeraTest##data:yield#X-squared=265.7,df=2,p-value<2.2e-16###Box-Ljungtest##data:yield#X-squared=12.253,df=1,p-value=0.0004644Taobao大数据部落SeriesyieldCDOCD5 10 15 20 25 30 35Lag#Warninginadf.test(yield):p-valuesmallerthanprintedp-value##AugmentedDickey-FullerTest##data:yield#Dickey-Fuller=-13.616,Lagorder=13,p-value=0.01#alternativehypothesis:stationary#Warninginpp.test(yield):p-valuesmallerthanprintedp-value
Taobao大数据部落##Phillips-PerronUnitRootTest##data:yield#Dickey-FullerZ(alpha)=-2410.8,Truncationlagparameter=9,#p-value=0.01#alternativehypothesis:stationary###ARCHLM-test;Nullhypothesis:noARCHeffects##data:yield#Chi-squared=146.83,df=12,p-value<2.2e-16#TOC\o"1-5"\h\z#* *#* GARCHModelFit *#* *##ConditionalVarianceDynamics# #GARCHModel:sGARCH(1,1)#MeanModel:ARFIMA(0,0,0)#Distribution:norm###OptimalParameters## Taobao大数据部落# EstimateStd.Error#mu -0.000575 0.000300## EstimateStd.Error#mu -0.000575 0.000300#omega 0.000005 0.000002#alphal 0.047347 0.004708#beta1 0.934878 0.006087##RobustStandardErrors:# EstimateStd.Error#mu -0.000575 0.000334#omega 0.000005 0.000006#alpha1 0.047347 0.012544#beta1 0.934878 0.010121##LogLikelihood:7255.899#tvalue-1.91512.437410.0571153.5890tvalue-1.721940.897573.7744192.36867Pr(>|t|)0.0554810.0147950.0000000.000000Pr(>|t|)0.0850810.3694170.0001600.000000##InformationCriteria## ###Akaike -5.4078#Bayes -5.3990#Shibata -5.4078#Hannan-Quinn-5.4046##WeightedLjung-BoxTestonStandardizedResiduals# # statistic p-value#Lag[1] 10.02 0.001547#Lag[2*(p+q)+(p+q)-1][2] 10.18 0.001714#Lag[4*(p+q)+(p+q)-1][5] 11.34 0.004141#d.o.f=0#H0:Noserialcorrelation##WeightedLjung-BoxTestonStandardizedSquaredResiduals## statisticp-value3.9520.04683statisticp-value3.9520.046835.9390.092976.8330.21355#Lag[1]#Lag[2*(p+q)+(p+q)-1][5]#Lag[4*(p+q)+(p+q)-1][9]#d.o.f=2###WeightedARCHLMTests##################StatisticShapeScaleP-ValueARCHLag[3]2.3210.5002.0000.1276ARCHLag[5]3.0691.4401.6670.2799ARCHLag[7]3.2102.3151.5430.4749NyblomstabilitytestJointStatistic:1.5527Taobao大数据部落#IndividualStatistics:#mu1.0709#omega0.1964#alpha10.1429#beta10.1513##AsymptoticCriticalValues(10%5%1%)#JointStatistic: 1.071.241.6#IndividualStatistic: 0.350.470.75##SignBiasTest# # t-value prob sig#SignBias 1.2545 0.2098#NegativeSignBias0.96500.3346#PositiveSignBias0.69060.4899#JointEffect 4.1751 0.2432###AdjustedPearsonGoodness-of-FitTest:# ##groupstatisticp-value(g-1)##12030.350.04752##23033.060.27549##34042.380.32717##45053.610.30205###Elapsedtime:0.7420433.利用得到的四组边缘分布,测度两两之间的相关性后,选择合适检uLa函数,建立四元CopuLa函数,并检验拟合程度;y2<-datahead(y2)# Pound Jpan Usd Eur#1 -0.016689192 -0.006422036 -0.004161304 0.001084608#2 0.000000000 0.005993930 0.000000000 -0.034008741#3 0.000000000 -0.006850273 0.008322209 -0.013969242#4 0.012517495 0.010275005 0.000000000 -0.001120290#5 0.012513888 -0.007277877 0.020798548 -0.011676878#6 -0.008342191 0.002140679 0.012474350 0.0072021572DdistributionofyieLds:cdf<-pobs(y2)
Taobao大数据部落测度两两之间的相关性plot(cdf)O建立四元Copula函数t.cop<-tCopula(dim=4,param=0.5,df=2,df.fixed=TRUE)fit<-fitCopula(data=cdf,copula=t.cop)检验拟合程度summary(fit)#$method#[1]"maximumpseudo-likelihood"##$loglik#[1]-839.8142##$convergence#[1]0##$coefficients# Esti
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 模具生产购买合同范本
- 工艺品买卖合同范本
- 取消协议房地产代理合同
- 校园服装购买合同
- 绿化服务合同范本
- 金鱼寄养服务协议
- 2024年度船舶租赁与燃油供应合同
- 2024宅地基转让合同范文
- 2024年度股权转让及收购合同范本3篇
- 河道整治桩基机械施工合同
- 2024秋期国家开放大学《公共政策概论》一平台在线形考(形考任务1至4)试题及答案
- DL∕T 516-2017 电力调度自动化运行管理规程
- 摇滚音乐课程教案
- 大学生生涯发展展示 (修改)
- 2024年烟叶分级工(高级)职业技能鉴定考试题库-下多选、判断题汇
- 电气工程师生涯人物访谈报告
- 中国儿童严重过敏反应诊断与治疗建议(2022年)解读
- 第12课《渔家傲 秋思》课件(30张PPT) 部编版语文九年级下册
- 隧道管片外观缺陷修补施工方案(完整版)
- 常见疾病的艾灸处方
- 纳米二氧化钛生产建设项目可行性研究报告
评论
0/150
提交评论