It is useful to be able to turn a time series into components. The function stl (with a lower-case letter L, not
numeral one) performs seasonal decomposition of a time series into seasonal, trend and irregular components
using loess. First, we make a time series object, specifying the start date and the frequency (as in Section
numeral one) performs seasonal decomposition of a time series into seasonal, trend and irregular components
using loess. First, we make a time series object, specifying the start date and the frequency (as in Section
24.4), then use stl to decompose the series:
up <- stl(high,"periodic")
plot(up)
ys <- factor(1+(yr>2002))
tapply(upper,ys,mean)
model1 <- lm(upper~index+sin(time*2*pi)+cos(time*2*pi))
summary(model1)
odel2 <-
lmer(upper~index+sin(time*2*pi)+cos(time*2*pi)+(1 | factor(yr)),REML=FALSE)
model3 <-
lmer(upper~sin(time*2*pi)+cos(time*2*pi)+(1 | factor(yr)),REML=FALSE)
anova(model2,model3)
means <- as.vector(tapply(upper,yr,mean))
model <- lm(means~I(1:19))
summary(model)
model <- lm(means[-1]~I(1:18))
summary(model)