金融时间序列分析 第一次作业

更新时间:2023-05-30 12:31:01 阅读量: 实用文档 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

张老师的金融计量课作业答案 R软件

1.1

a.用百分数表示简单月收益率(略)

b.简单收益率换成对数收益率(略) c.把对数收益率用百分比表示出来(略)

d.对数收益率零均值检验( =0.05) 1>对于American Express data: dailylogre$V2

t = 1.6044, df = 2518, p-value = 0.1087

alternative hypothesis: true mean is not equal to 0

95 percent confidence interval: -0.01596993 0.15972365 sample estimates: mean of x 0.07187686 故接受原假设

2>对于Caterpillar data: dailylogre$V3

t = 1.4369, df = 2518, p-value = 0.1509

alternative hypothesis: true mean is not equal to 0

95 percent confidence interval:-0.02245558 0.14560208 sample estimates: mean of x 0.06157325 故接受原假设 3>对于Starbucks

张老师的金融计量课作业答案 R软件

data: dailylogre$V4

t = 1.6162, df = 2518, p-value = 0.1062

alternative hypothesis: true mean is not equal to 0

95 percent confidence interval:-0.02098409 0.21776370 sample estimates: mean of x 0.09838981 故接受原假设

1.2

a.用百分数表示简单月收益率(略)

b.简单收益率换成对数收益率(略) c.把对数收益率用百分比表示出来(略)

d.对数收益率零均值检验( =0.05) 1>对于IBM

data: dailylogre$V2

t = 2.1095, df = 347, p-value = 0.03562

alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.05899196 1.68541655 sample estimates: mean of x 0.8722043 故拒绝原假设

张老师的金融计量课作业答案 R软件

2>对于VW

data: dailylogre$V3

t = 4.3846, df = 347, p-value = 1.542e-05

alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.5955359 1.5644506 sample estimates: mean of x 1.079993 故拒绝原假设

3>对于EW

data: dailylogre$V4

t = 4.6899, df = 347, p-value = 3.937e-06

alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.8250521 2.0169110 sample estimates: mean of x 1.420982 故拒绝原假设

4>对于SP

data: dailylogre$V5

t = 3.3417, df = 347, p-value = 0.0009235

alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.329396 1.271850 sample estimates: mean of x 0.8006232 故拒绝原假设

1.3

a.

12

2004 2005 =1975 =1975 =1

平均年对数收益率==

其中, 为第 年对数收益率, 为第 年第 月的月对数收益率 则SP的平均年对数收益率=9.607479% b.

= =1× 0.09607479(2004 1975)=16.21876

1.4

张老师的金融计量课作业答案 R软件

a. 0: =0, =0.05 建立检验统计量 =

计算结果为 =1.81106 =0.070132

"Accept Null Hypothesis" 故接受原假设

b. 0: =0, =0.05 建立检验统计量

= (0,1)

计算结果为 = 6.23215

=4.60076e 10

"Reject Null Hypthesis;Accept Alternative Hypothesis" 故拒绝原假设,接受被择假设

(0,1)

1.5

a.计算月对数收益率(略)

b.

c. 汇率对数收益率的经验特征

Appendix

1.1R语言程序源码

setwd("F:/Financial Econometrics/Homework Guide/TsayDat") dailyre<-read.table(file="d-3stock.txt") dailyre$V2=dailyre$V2*100 dailyre$V3=dailyre$V3*100 dailyre$V4=dailyre$V4*100 summary(dailyre) sd(dailyre) library(fBasics) skewness(dailyre)

张老师的金融计量课作业答案 R软件

kurtosis(dailyre)-3

dailylogre<-dailyre

dailylogre$V2=log(1+dailyre$V2/100) dailylogre$V3=log(1+dailyre$V3/100) dailylogre$V4=log(1+dailyre$V4/100)

dailylogre$V2=dailylogre$V2*100 dailylogre$V3=dailylogre$V3*100 dailylogre$V4=dailylogre$V4*100 summary(dailylogre) sd(dailylogre) skewness(dailylogre) kurtosis(dailylogre)-3

t.test(x=dailylogre$V2,alternative="two.sided",mu=0) t.test(x=dailylogre$V3,alternative="two.sided",mu=0) t.test(x=dailylogre$V4,alternative="two.sided",mu=0)

1.2R语言程序源码

setwd("F:/Financial Econometrics/Homework Guide/TsayDat") dailyre<-read.table(file="m-ibm3dx7503.txt") dailyre$V2=dailyre$V2*100 dailyre$V3=dailyre$V3*100 dailyre$V4=dailyre$V4*100 dailyre$V5=dailyre$V5*100

summary(dailyre) sd(dailyre) library(fBasics) skewness(dailyre) kurtosis(dailyre)-3

dailylogre<-dailyre

dailylogre$V2=log(1+dailyre$V2/100) dailylogre$V3=log(1+dailyre$V3/100) dailylogre$V4=log(1+dailyre$V4/100) dailylogre$V5=log(1+dailyre$V5/100)

dailylogre$V2=dailylogre$V2*100 dailylogre$V3=dailylogre$V3*100 dailylogre$V4=dailylogre$V4*100 dailylogre$V5=dailylogre$V5*100

summary(dailylogre) sd(dailylogre) skewness(dailylogre) kurtosis(dailylogre)-3

t.test(x=dailylogre$V2,alternative="two.sided",mu=0) t.test(x=dailylogre$V3,alternative="two.sided",mu=0) t.test(x=dailylogre$V4,alternative="two.sided",mu=0) t.test(x=dailylogre$V5,alternative="two.sided",mu=0)

1.3R语言程序源码 接1.2

r<-sum(dailylogre$V5)/(2004-1975) exp(r*(2004-1975)/100)

1.4R语言程序源码

建立名为z.test的函数用于检验偏度

z.test<-function(skewness,n,alpha,alternative="two.sided"){ options(digits=6) result<-list()

t<-(skewness/sqrt(6/n))

张老师的金融计量课作业答案 R软件

p<-pnorm(t,lower.tail=FALSE) result$t<-t result$p<-p

if(alternative=="two.sided"){ p<-2*p result$p<-p }

else return("Unexpected Error") if(p<alpha){

result$conclusion<-("Accept Null Hypothesis") }

else {result$conclusion<-("Reject Null Hypthesis;Accept Alternative Hypothesis") }

return(result) }

建立名为z.test2的函数用于检验超额峰度

z.test2<-function(kurtosis,n,alpha,alternative="two.sided"){ options(digits=6) result<-list()

t<-((kurtosis-3)/sqrt(24/n)) p<-pnorm(t,lower.tail=FALSE) result$t<-t result$p<-p

if(alternative=="two.sided"){ p<-(min(2*p,2(1-p))) result$p<-p }

else return("Unexpected Error") if(p>alpha){

result$conclusion<-("Accept Null Hypothesis") }

else {result$conclusion<-("Reject Null Hypthesis;Accept Alternative Hypothesis") }

return(result) }

1.5R语言程序源码

setwd("F:/Financial Econometrics/Homework Guide/TsayDat") fxca<-read.table(file="d-fxca00.txt") fxuk<-read.table(file="d-fxuk00.txt") fxjp<-read.table(file="d-fxjp00.txt") fxeu<-read.table(file="d-fxeu00.txt")

fxca$V2=log(1+fxca$V2) fxuk$V2=log(1+fxuk$V2) fxjp$V2=log(1+fxjp$V2) fxeu$V2=log(1+fxeu$V2)

mean(fxca$V2) mean(fxuk$V2) mean(fxjp$V2) mean(fxeu$V2) min(fxca$V2) min(fxuk$V2) min(fxjp$V2) min(fxeu$V2) max(fxca$V2) max(fxuk$V2) max(fxjp$V2) max(fxeu$V2)

sd(fxca$V2) sd(fxuk$V2) sd(fxjp$V2) sd(fxeu$V2)

library(fBasics)

张老师的金融计量课作业答案 R软件

skewness(fxca$V2) skewness(fxuk$V2) skewness(fxjp$V2) skewness(fxeu$V2) kurtosis(fxca$V2)-3 kurtosis(fxuk$V2)-3 kurtosis(fxjp$V2)-3

本文来源:https://www.bwwdw.com/article/an64.html

Top