par1 <- as.numeric(par1) #seasonal period if (par2 != 'periodic') par2 <- as.numeric(par2) #s.window par3 <- as.numeric(par3) #s.degree if (par4 == '') par4 <- NULL else par4 <- as.numeric(par4)#t.window par5 <- as.numeric(par5)#t.degree if (par6 != '') par6 <- as.numeric(par6)#l.window par7 <- as.numeric(par7)#l.degree if (par8 == 'FALSE') par8 <- FALSE else par9 <- TRUE #robust nx <- length(x) x <- ts(x,frequency=par1) if (par6 != '') { m <- stl(x,s.window=par2, s.degree=par3, t.window=par4, t.degre=par5, l.window=par6, l.degree=par7, robust=par8) } else { m <- stl(x,s.window=par2, s.degree=par3, t.window=par4, t.degre=par5, l.degree=par7, robust=par8) } m$time.series m$win m$deg m$jump m$inner m$outer bitmap(file='test1.png') plot(m,main=main) dev.off() mylagmax <- nx/2 bitmap(file='test2.png') op <- par(mfrow = c(2,2)) acf(as.numeric(x),lag.max = mylagmax,main='Observed') acf(as.numeric(m$time.series[,'trend']),na.action=na.pass,lag.max = mylagmax,main='Trend') acf(as.numeric(m$time.series[,'seasonal']),na.action=na.pass,lag.max = mylagmax,main='Seasonal') acf(as.numeric(m$time.series[,'remainder']),na.action=na.pass,lag.max = mylagmax,main='Remainder') par(op) dev.off() bitmap(file='test3.png') op <- par(mfrow = c(2,2)) spectrum(as.numeric(x),main='Observed') spectrum(as.numeric(m$time.series[!is.na(m$time.series[,'trend']),'trend']),main='Trend') spectrum(as.numeric(m$time.series[!is.na(m$time.series[,'seasonal']),'seasonal']),main='Seasonal') spectrum(as.numeric(m$time.series[!is.na(m$time.series[,'remainder']),'remainder']),main='Remainder') par(op) dev.off() bitmap(file='test4.png') op <- par(mfrow = c(2,2)) cpgram(as.numeric(x),main='Observed') cpgram(as.numeric(m$time.series[!is.na(m$time.series[,'trend']),'trend']),main='Trend') cpgram(as.numeric(m$time.series[!is.na(m$time.series[,'seasonal']),'seasonal']),main='Seasonal') cpgram(as.numeric(m$time.series[!is.na(m$time.series[,'remainder']),'remainder']),main='Remainder') par(op) dev.off() load(file='createtable') a<-table.start() a<-table.row.start(a) a<-table.element(a,'Seasonal Decomposition by Loess - Parameters',4,TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'Component',header=TRUE) a<-table.element(a,'Window',header=TRUE) a<-table.element(a,'Degree',header=TRUE) a<-table.element(a,'Jump',header=TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'Seasonal',header=TRUE) a<-table.element(a,m$win['s']) a<-table.element(a,m$deg['s']) a<-table.element(a,m$jump['s']) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'Trend',header=TRUE) a<-table.element(a,m$win['t']) a<-table.element(a,m$deg['t']) a<-table.element(a,m$jump['t']) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'Low-pass',header=TRUE) a<-table.element(a,m$win['l']) a<-table.element(a,m$deg['l']) a<-table.element(a,m$jump['l']) a<-table.row.end(a) a<-table.end(a) table.save(a,file='mytable.tab') a<-table.start() a<-table.row.start(a) a<-table.element(a,'Seasonal Decomposition by Loess - Time Series Components',6,TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'t',header=TRUE) a<-table.element(a,'Observed',header=TRUE) a<-table.element(a,'Fitted',header=TRUE) a<-table.element(a,'Seasonal',header=TRUE) a<-table.element(a,'Trend',header=TRUE) a<-table.element(a,'Remainder',header=TRUE) a<-table.row.end(a) for (i in 1:nx) { a<-table.row.start(a) a<-table.element(a,i,header=TRUE) a<-table.element(a,x[i]) a<-table.element(a,x[i]+m$time.series[i,'remainder']) a<-table.element(a,m$time.series[i,'seasonal']) a<-table.element(a,m$time.series[i,'trend']) a<-table.element(a,m$time.series[i,'remainder']) a<-table.row.end(a) } a<-table.end(a) table.save(a,file='mytable1.tab')
|