In [2]:
# from the stats package

# decompose
# stl # LOESS

In [3]:
data(co2, package = "TSA")

In [9]:
# we can't set the moving window manually
decomp.co2 <- decompose(co2)

In [5]:
class(decomp.co2)


'decomposed.ts'

In [6]:
str(decomp.co2)


List of 6
 $ x       : Time-Series [1:132] from 1994 to 2005: 363 364 365 364 364 ...
 $ seasonal: Time-Series [1:132] from 1994 to 2005: 3.56 4.2 4.48 4.83 5.19 ...
 $ trend   : Time-Series [1:132] from 1994 to 2005: NA NA NA NA NA ...
 $ random  : Time-Series [1:132] from 1994 to 2005: NA NA NA NA NA ...
 $ figure  : num [1:12] 3.56 4.2 4.48 4.83 5.19 ...
 $ type    : chr "additive"
 - attr(*, "class")= chr "decomposed.ts"

In [7]:
plot(decomp.co2)



In [11]:
stl.co2 <- stl(co2, s.window = "periodic")

In [12]:
plot(stl.co2)



In [ ]: