版主好,各位金融统计的同仁好,小弟刚入门,请教的都是很基础的问题,还望大家包涵。
要做的课题是用 dividend price ratio 去预测 S&P 的monthly return.
数据格式是
colomn 1: gross monthly return on S&P
colomn 2: gross monthly return on 90days risk free bond
colomn 3: dividend price ratio
代码如下
library(rugarch);
dat=read.csv('C:\\redp.dat',header=F);
logexr=log(dat$V1)-log(dat$V2); # log of gross excess return
dp=log(dat$V3); # log dividend price ratio
spec = ugarchspec(variance.model = list(model = "eGARCH", garchOrder = c(1,1),
external.regressors = as.matrix(dp)),
mean.model = list(armaOrder=c(0,0), include.mean = T, external.regressors = as.matrix(dp)), distribution.model = "norm");
myfit = ugarchfit(spec, as.matrix(logexr));
forc = ugarchforecast(res, n.ahead=1,external.forecasts = list(mregfor = as.matrix(dp[700]), vregfor = as.matrix(dp[700]) ));
最后一行命令无法执行
显示 错误于format.default(Dates[n], "%m/%d/%y") : 'trim'参数不对
恳请过来人指点迷津,谢谢了。