金融时间序列分析用R语言画简单收益率和对数收益率的ACF图?!

数据“d-intc7208.txt”为英特尔1972年1月15日到2008年12
月31日的日简单收益率,
1). 画出简单收益率和对数收益率的ACF图,
2). 并检查简单收益率和对数收益率的5个和10个的自相关系数是
否为同时0.
我的代码:

int <- read.table("d-intc7208.txt", head=T)
head(int)
int.l <- log(int+1)

acf(int[,2], lag.max = 15,type = "correlation", plot = TRUE,main='int monthly

acf(int.l[,2], lag.max = 15,type = "correlation", plot = TRUE,main='int monthly
log return')

Box.test(int[,2], lag = 5, type = "Ljung-Box")
Box.test(int[,2], lag = 10, type = "Ljung-Box")
Box.test(int.l[,2], lag = 5, type = "Ljung-Box")
Box.test(int.l[,2], lag = 10, type = "Ljung-Box")

运行结果有以下错误,怎么办?

> int <- read.table("d-intc7208.txt", head=T)
错误于file(file, "rt") : 无法打开链结
此外: 警告信息:
In file(file, "rt") :
无法打开文件'd-intc7208.txt': No such file or directory

+ acf(int.l[,2], lag.max = 15,type = "correlation", plot = TRUE,main='int monthly
错误: 意外的符号 in:
"
acf(int.l[,2], lag.max = 15,type = "correlation", plot = TRUE,main='int"
> log return')
错误: 意外的符号 in "log return"

acf(int[,2], lag.max = 15,type = "correlation", plot = TRUE,main='int monthly

acf(int.l[,2], lag.max = 15,type = "correlation", plot = TRUE,main='int monthly
log return')

Box.test(int[,2], lag = 5, type = "Ljung-Box")
Box.test(int[,2], lag = 10, type = "Ljung-Box")
Box.test(int.l[,2], lag = 5, type = "Ljung-Box")
Box.test(int.l[,2], lag = 10, type = "Ljung-Box")

运行结果有以下错误,怎么办?

> int <- read.table("d-intc7208.txt", head=T)
错误于file(file, "rt") : 无法打开链结
此外: 警告信息:
In file(file, "rt") :
无法打开文件'd-intc7208.txt': No such file or directory

+ acf(int.l[,2], lag.max = 15,type = "correlation", plot = TRUE,main='int monthly
错误: 意外的符号 in:
"
acf(int.l[,2], lag.max = 15,type = "correlation", plot = TRUE,main='int"
> log return')
错误: 意外的符号 in "log return"
温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-05-09
第一个问题的原因应该是没有把该txt文件放到R语言默认的文件夹下,所以读不到。用setwd("你的目录")
相似回答