Code:

```
set.seed(10)
dat <- data.frame(value=rnorm(1000, sd=10), time=1:1000)
len <- nrow(dat)
dat$moving_ave <- rep(NA, len)
for(i in 1:len) {
dat$moving_ave[i] <- mean(dat$value[1:i])
}
ggplot(dat, aes(y=moving_ave, x = time)) + geom_smooth() +
geom_line(size=.8, color="black")
```

The problem is that the average doesn't become stable (rnorm should give a rough line around 0 but the wide stan dev. causes the beginning of the graph to have huge jumps; i.e., the mean is grossly effected by the small n). This is not a new problem and I see there's weighted means to deal with this problem: http://www.inside-r.org/packages/cran/TTR/docs/GD

However, even with these weighted means the mean is not stable and is only slightly improved. So I tried the TTR without really digging into time series (not my area and I realize this is huge so I need direction of where to go). I played with the following tries at weighting:

Code:

```
library(TTR)
dat$SMA <- SMA(dat$value)
dat$EMA <- EMA(dat$value)
dat$WMA <- WMA(dat$value)
dat$DEMA <- DEMA(dat$value)
dat$ZLEMA <- ZLEMA(dat$value)
library(reshape2)
mdat <- melt(dat, id=c('value', 'time', 'moving_ave'), variable="type")
ggplot(mdat, aes(y=value, x = time, group=type, color=type)) +
geom_smooth() +
geom_line(size=.5) +
geom_line(size=.5, aes(y=moving_ave), color="black", shape=2) +
facet_grid(~type)
```

This seemed to make it worse. Help lead me to smooth this front end of the data in a reasonable way.