Questions tagged [time-series]

A Time series is a sequence of data points with values measured at successive times (either in continuous time or at discrete time periods). Time series analysis exploits this natural temporal ordering to extract meaning and trends from the underlying data.

Time series data is data with a pattern (“trend”) over time. Quantitative forecasting can be applied when two conditions are satisfied:

  1. numerical information about the past is available;
  2. it is reasonable to assume that some aspects of the past patterns will continue into the future.

Time series data are useful when you are forecasting something that is changing over time (e.g., stock prices, sales figures, profits, etc.). Examples of time series data include:

  • Daily IBM stock prices
  • Monthly rainfall
  • Quarterly sales results for Amazon
  • Annual Google profits

https://www.otexts.org/fpp/1/4

Time series models attempt to make use of the natural one-way ordering of time so that values for a given period will be expressed as a function of past values. This same idea is used in time series forecasting — future values based on past data.

Typically, time series data points are spaced at uniform time intervals.

A time series model will generally reflect the fact that observations close together in time will be more closely related than observations further apart.

As a place to start, take a look at Wikipedia's page on time series. For further reading, refer to the Statsoft website which has an online textbook on time series analysis.

For time series analysis in , consider looking at the Time Series Task View and questions tagged for the zoo package and for the xts package.


Tag usage:

Questions on tag should be about implementation and programming problems, not about the statistical or theoretical properties of the technique. Consider whether your question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis or Data Science, the StackExchange site for Data Science related topics like time series.

15192 questions
22
votes
5 answers

Decomposing trend, seasonal and residual time series elements

I have a DataFrame with a few time series: divida movav12 var varmovav12 Date 2004-01 0 NaN NaN NaN 2004-02 0 NaN NaN NaN 2004-03 …
aabujamra
  • 4,494
  • 13
  • 51
  • 101
22
votes
3 answers

Time series forecasting, dealing with known big orders

I have many data sets with known outliers (big orders) data <-…
22
votes
7 answers

How can I simply calculate the rolling/moving variance of a time series in python?

I have a simple time series and I am struggling to estimate the variance within a moving window. More specifically, I cannot figure some issues out relating to the way of implementing a sliding window function. For example, when using NumPy and…
Barry
  • 377
  • 2
  • 4
  • 7
22
votes
4 answers

Selecting Data between Specific hours in a pandas dataframe

My Pandas Dataframe frame looks something like this 1. 2013-10-09 09:00:05 2. 2013-10-09 09:05:00 3. 2013-10-09 10:00:00 4. ............ 5. ............ 6. ............ 7. 2013-10-10 09:00:05 8. 2013-10-10 09:05:00 9. 2013-10-10…
itsaruns
  • 659
  • 2
  • 11
  • 16
21
votes
5 answers

Postgresql generate_series of months

I'm trying to generate a series in PostgreSQL with the generate_series function. I need a series of months starting from Jan 2008 until current month + 12 (a year out). I'm using and restricted to PostgreSQL 8.3.14 (so I don't have the timestamp…
21
votes
4 answers

Pandas resample with start date

I'd like to resample a pandas object using a specific date (or month) as the edge of the first bin. For instance, in the following snippet I'd like my first index value to be 2020-02-29 and I'd be happy specifying start=2 or start="2020-02-29". >>>…
jsignell
  • 3,072
  • 1
  • 22
  • 23
21
votes
3 answers

How to train a RNN with LSTM cells for time series prediction

I'm currently trying to build a simple model for predicting time series. The goal would be to train the model with a sequence so that the model is able to predict future values. I'm using tensorflow and lstm cells to do so. The model is trained with…
Jakob
  • 369
  • 1
  • 3
  • 11
21
votes
5 answers

How can I perform K-means clustering on time series data?

How can I do K-means clustering of time series data? I understand how this works when the input data is a set of points, but I don't know how to cluster a time series with 1XM, where M is the data length. In particular, I'm not sure how to update…
Jaz
  • 581
  • 2
  • 6
  • 10
21
votes
5 answers

Replace -inf, NaN and NA values with zero in a dataset in R

I am trying to run some trading strategies in R. I have downloaded some stock prices and calculated returns. The new return dataset has a number of -inf, NaN, and NA values. I am reproducing a row of the dataset (log_ret). Its a zoo…
user2641784
  • 377
  • 3
  • 5
  • 13
21
votes
1 answer

Python pandas time series interpolation and regularization

I am using Python Pandas for the first time. I have 5-min lag traffic data in csv format: ... 2015-01-04 08:29:05,271238 2015-01-04 08:34:05,329285 2015-01-04 08:39:05,-1 2015-01-04 08:44:05,260260 2015-01-04 08:49:05,263711 ... There are several…
riccamini
  • 1,161
  • 1
  • 13
  • 29
21
votes
5 answers

Calculate days since last event in R

My question involves how to calculate the number of days since an event last that occurred in R. Below is a minimal example of the data: df <-…
amo
  • 3,030
  • 4
  • 25
  • 42
21
votes
3 answers

Distance calculation between rows in Pandas Dataframe using a distance matrix

I have the following Pandas DataFrame: In [31]: import pandas as pd sample = pd.DataFrame({'Sym1': ['a','a','a','d'],'Sym2':['a','c','b','b'],'Sym3':['a','c','b','d'],'Sym4':['b','b','b','a']},index=['Item1','Item2','Item3','Item4']) In [32]:…
Clayton
  • 1,525
  • 5
  • 19
  • 35
20
votes
3 answers

Using a date field in a ts?

I wonder how I can make use of an already existing date field when creating a ts in R. Sometimes you simply have a date before you have a ts object, e.g. x <- as.Date("2008-01-01") + c(30,60,90,120,150) # add some data to it df =…
Matt Bannert
  • 27,631
  • 38
  • 141
  • 207
20
votes
2 answers

Holt-Winters time series forecasting with statsmodels

I tried forecasting with holt-winters model as shown below but I keep getting a prediction that is not consistent with what I expect. I also showed a visualization of the plot Train = Airline[:130] Test = Airline[129:] from…
Mujeebla
  • 203
  • 1
  • 2
  • 6
20
votes
2 answers

Plotting a time series?

I have a data set which has dates in the first column, and a "result" integer which is either 1 or 0. The date column was successfully converted to a time object. I tried to plot the values directly using matplotlib's plot function, but that did not…
RedaBitar
  • 323
  • 1
  • 4
  • 10