我正在为不同的Garch型号规格运行一个程序。为了比较,我想保存
show(fit)
输出为A
.txt
文件。我试过了
sink()
函数,但文本文件为空。
for (p in c(1:3)){
for (q in c(1:3)){
myfile <- paste("GARCH",p,q, ".rda", sep="")
spec <- ugarchspec(mean.model = list(armaOrder = c(1, 0),
include.mean = TRUE), variance.model = list(model = 'mcsGARCH', garchOrder = c(p, q), external.regressors = ext_reg), distribution = 'nig')
# DailyVar is the required xts object of the forecast daily variance
myoutput <- paste("GARCH",p,q, "_Output.txt", sep="")
sink(myoutput)
fit <- ugarchfit(data = R_i, spec = spec, DailyVar = sigma_f^2)
show(fit)
sink()
save(fit, file = myfile) # Saving the whole .rda file works
我看到了
Sin()
为我工作。但是我怎样才能保存
rugarch
输出?