[R] sink function

nuncio m
Fri, 23 Jul 2010 12:45:06 -0000

I have the following code to write the output from auto.arima function.  The
issue is not in finding the model but to divert its out put
fit to a file order_fit.txt. code runs but nothing is written to
order_fit.txt
where am I going wrong

library(forecast)
for (i in 1:2) {
filen = paste("file",i,".txt",sep="")
data <- read.table(filen)
dat1 <- data[,1]
xt <- ts(dat1,start=c(1978,11),end=c(2006,12),frequency=12)
#dat1[dat1 == -99.989998] <- NA
if (min(dat1) != max(dat1)){
fit <- auto.arima(xt,D=1)

*sink(file="order_fit.txt")
fit
sink()*

residfit <- residuals(fit)
filenou1 =
paste("fileree",i,"_out",".txt",sep="")
residfit
write.table(residfit,filenou1,sep="\t",col.names=FALSE,row.names=FALSE,quote=FALSE)

}else{
*fiit <- "ARIMA(-6,-6,-6)(-6,-6,-6)[12]"
sink(file="order_fit.txt")
fiit
sink()*
filenou1 =
paste("fileree",i,"_out",".txt",sep="")
residfit=rep(-99.99,338)
residfit
write.table(residfit,filenou1,sep="\t",col.names=FALSE,row.names=FALSE,quote=FALSE)
rm(data,dat1,residfit,xt)
}
}

--
Nuncio.M
Research Scientist
National Center for Antarctic and Ocean research
Head land Sada
Vasco da Gamma
Goa-403804

	[[alternative HTML version deleted]]