R in Time Series: White Noise and Random Walk

This tutorial introduces white noise and random walk.

1  White Noise

1.1  Motivation

When we fit mathematical models to time series data, if the model captured most of the deterministic features of the time series, the residual error series should appear to be a realization of independent random variable from some probability distribution. Due to this criteria of judging how good a model is in fitting given data, it seems natural to build models up from a model of independent randon variation, known as discrete white noise.

Posted in How-to, Knowledge, Mathematics, R Tagged with: , ,

Dive into Python 3

This post summaries the key points covered in the book: Dive into Python 3, by Mark Pilgrim.

Posted in How-to, Python Tagged with:

R in Time Series: Holt-Winters Smoothing and Forecast

This tutorial tells about how to do Holt-WInters smoothing and forecast in R.

1  Basics of Holt-Winters method

where $a_t$, $b_t$, and $s_t\,$are the estimated level, slope, and seasonal effect at time t, and $\alpha$, $\beta$, and $\gamma\,$are the smoothing parameters. Read more ›

Posted in How-to, R Tagged with: , , , ,

R in Time Series: Exponential Smoothing

This tutorial talks about the exponential smoothing and forecasts based on it.

1  Objective and Assumptions

Given a past history $\{x_1,x_2,\cdots,x_n\}\Longrightarrow$we want to predict some future value $x_{n+k}$.

We assume that:

1. We assume there is no systematic trend or seasonal effects in the process, or that these have been identified and removed.
2. The mean of the process can change from one time step to the next, but we have no information about the likely direction of these changes.
Posted in How-to, R Tagged with: , , , , ,

R in Time Series: Cross-correlation

This tutorial talks about computing cross-correlation in R.

Suppose we have time series models for variables x and y that are stationary in mean and variance.  The variables may each be serially correlated, and correlated with each other at different time lags. Read more ›

Posted in How-to, R Tagged with: , ,

R in Time Series: Autocorrelation in R

This tutorial presents basics of autocorrelation in R.

1  Stationality vs Ergodicity

The mean function of a time series model is

which is, in general, a function of time t. Since $x_t$can have different realization at t, above definition of expectation is an average taken across the ensemble of all the possible times series that might have been realized by the time series model.

The ensemble constitutes the entire population. If we have a time series model, we can simulate more than one time series. However, with historical data, we usually only have a single time series. So, all we can do, without assuming a mathematical structure for the trend, is to estimate the mean at each sample point by the corresponding observed value. Read more ›

Posted in How-to, R Tagged with: , , ,

R in Time Series: Seasonal Decomposition By Loess

This tutorial talks about how to do seasonal decomposition by Loess.

The Seasonal Trend Decomposition using Loess (STL) is an algorithm that was developed to help to divide up a time series into three components namely: the trend, seasonality and remainder. The methodology was presented by Robert Cleveland, William Cleveland, Jean McRae and Irma Terpenning in the Journal of Official Statistics in 1990. This paper can be downloaded here. Read more ›

Posted in How-to, R Tagged with: , , ,

R in Time Series: Seasonal Decomposition By Moving Average

This tutorial tells about how to do seasonal decomposition by moving average in R.

There are two kinds of classical decomposition models:

1. Additive model: $x_t=m_t+s_t+\epsilon_t$
2. Multiplicative model: $x_t=m_t\cdot s_t+\epsilon_t$
Posted in How-to, R Tagged with: , ,

R in Time Series: Intersection between two data series

This tutorial tells a tip of R in time series: extract intersection between two data series. Read more ›

Posted in How-to, R Tagged with: ,

R in Time Series: Trend and Seasonal Variation

This tutorial talks about one aspect of R in time series: trend and seasonal variation.

Trend refers to a systematic change in a time series that does not appear to be periodic.

Seasonal variation refers to a repeating pattern within each year in a time series. Read more ›

Posted in How-to, R Tagged with: , ,