source("ftp://stat.ethz.ch/NDK/Source-WBL-1/R/f.acf.R")
t.h <- 4; t.w <- 6
set.seed(7)
#ps.latex("/u/sfs/wbl1/ueb/aufgaben/zeit-arima-modellwahl-1.ps",
         main.space=T, height=t.h, width=t.w)
ts1 <- arima.sim(n=200, model=list(order=c(2,0,1), ar=c(0.8, -0.2),
                          ma=c(0.7)))
f.acf(ts1, main="Zeitreihe 1")
#ps.end()

#ps.latex("/u/sfs/wbl1/ueb/aufgaben/zeit-arima-modellwahl-2.ps",
         main.space=T, height=t.h, width=t.w)
ts2 <- arima.sim(n=200, model=list(order=c(1,0,3), ar=-0.6, 
                          ma=c(-0.7,0.4,0.6)))
f.acf(ts2, main="Zeitreihe 2")
#ps.end()

#ps.latex("/u/sfs/wbl1/ueb/aufgaben/zeit-arima-modellwahl-3.ps",
         main.space=T, height=t.h, width=t.w)
ts3 <- arima.sim(n=199, model=list(order=c(2,1,0), ar=c(0.4, -0.5)))
f.acf(ts3, main="Zeitreihe 3")
#ps.end()

#ps.latex("/u/sfs/wbl1/ueb/aufgaben/zeit-arima-modellwahl-4.ps",
         main.space=T, height=t.h, width=t.w)
f.acf(diff(ts3), main="diff(Zeitreihe 3)")
#ps.end()

t.dat <- data.frame(ts1=ts1,ts2=ts2,ts3=ts3)
str(t.dat)

##write.table(t.dat,file="/u/ftp/Teaching/Datasets/NDK/ARIMAsim2.dat",
##           row.names=F, col.names=T)

t.url <- "http://stat.ethz.ch/Teaching/Datasets/NDK/ARIMAsim2.dat"
t.d <- ts(read.table(t.url, header=T))
str(t.d)
plot(t.d)
