meanreg

Do a regression to get the mean of a ts object. There are a couple reasons you might use this function rather than calling mean.

Arguments

meanreg <- function(y, start=NULL, end=NULL)

Examples

x <- ts(rnorm(120), start=c(2010,1), frequency=12)
meanreg(x) # mean
meanreg(x, start=c(2014,1)) # mean of x from Jan 2014 to the end
meanreg(x, end=c(2017,4)) # mean of x through Apr 2017
meanreg(x, start=c(2014,1), end=c(2017,4))