In [4]:
# source: http://www.escet.urjc.es/biodiversos/R/milk.csv
milk <- read.csv("data/milk.csv", header=T, sep=",")
In [5]:
head(milk)
We will need to transform this into a time series before further processing.
In [10]:
# one data point / month, beginning in January 1994
milk.ts <- ts(data=milk$milk, start=c(1994, 1), frequency=12)
We can see that milk production shows an upward trend and is seasonal.
In [11]:
plot(milk.ts, ylab = "milk production / cow", main="US monthly milk production")
In [13]:
milk.ma <- decompose(milk.ts)
In [16]:
plot(milk.ma)
We see an upward trend and very predictable seasonalilty, but the random part doesn't look random.
In [22]:
str(milk.ma)
In [23]:
milk.ma$trend
In [18]:
milk.loess <- stl(milk.ts, s.window = "periodic")
In [19]:
plot(milk.loess)
We see an upward trend and very predictable seasonalilty, but the remainder part has outliers:
In [ ]: