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
13
votes
1 answer

How to generate noisy mock time series or signal (in Python)

Quite often I have to work with a bunch of noisy, somewhat correlated time series. Sometimes I need some mock data to test my code, or to provide some sample data for a question on Stack Overflow. I usually end up either loading some similar dataset…
Swier
  • 4,047
  • 3
  • 28
  • 52
13
votes
4 answers

Why do I get a Keras LSTM RNN input_shape error?

I keep getting an input_shape error from the following code. from keras.models import Sequential from keras.layers.core import Dense, Activation, Dropout from keras.layers.recurrent import LSTM def _load_data(data): """ data should be…
Ravaal
  • 3,233
  • 6
  • 39
  • 66
13
votes
2 answers

Calculate angle (degrees) in Python between line (with slope x) and horizontal

I need to calculate the angle between a line and the horizontal. My high school maths seems to be failing me. import matplotlib.pyplot as plt import numpy as np x = [8450.0, 8061.0, 7524.0, 7180.0, 8247.0, 8929.0, 8896.0, 9736.0, 9658.0, 9592.0] y…
ljc
  • 943
  • 2
  • 10
  • 26
13
votes
1 answer

Calculating Dynamic Time Warping Distance in a Pandas Data Frame

I want to calculate Dynamic Time Warping (DTW) distances in a dataframe. The result must be a new dataframe (a distance matrix) which includes the pairwise dtw distances among each row. For Euclidean Distance I use the following code: from…
venom
  • 2,563
  • 2
  • 11
  • 8
13
votes
1 answer

"circular" mean in R

Given a dataset of months, how do I calculate the "average" month, taking into account that months are circular? months = c(1,1,1,2,3,5,7,9,11,12,12,12) mean(months) ## [1] 6.333333 In this dummy example, the mean should be in January or December. …
generic_user
  • 3,430
  • 3
  • 32
  • 56
13
votes
4 answers

Creating a running counting variable in R?

I have a dataset of soccer match results, and I am hoping to learn R by creating a running set of ratings similar to the World Football Elo formula. I am running into trouble with things that seem to be simple in Excel aren't exactly intuitive in…
Matt Barger
  • 173
  • 1
  • 6
13
votes
4 answers

What's the opposite function to lag for an R vector/dataframe?

I have a problem dealing with time series in R. #--------------read data wb = loadWorkbook("Countries_Europe_Prices.xlsx") df = readWorksheet(wb, sheet="Sheet2") x <- df$Year y <- df$Index1 y <- lag(y, 1, na.pad = TRUE) cbind(x, y) It gives me…
Gilles Cosyn
  • 435
  • 2
  • 9
  • 17
13
votes
3 answers

How can I select 'last business day of the month' in Pandas?

I'm trying to subset a DataFrame on the condition that is the last of the month. I used: df['Month_End'] = df.index.is_month_end sample = df[df['Month_End'] == 1] This works, but I'm working with stock market data, so I'm missing all the instances…
hernanavella
  • 5,462
  • 8
  • 47
  • 84
13
votes
3 answers

Time-series boxplot in pandas

How can I create a boxplot for a pandas time-series where I have a box for each day? Sample dataset of hourly data where one box should consist of 24 values: import pandas as pd n = 480 ts = pd.Series(randn(n), …
Fred S
  • 1,421
  • 6
  • 21
  • 37
13
votes
1 answer

Aggregate continuous ranges of dates

Let's say you have the following PostgreSQL sparse table listing reservation dates: CREATE TABLE reserved_dates ( reserved_days_id SERIAL NOT NULL, reserved_date DATE NOT NULL ); INSERT INTO reserved_dates (reserved_date)…
13
votes
3 answers

Seasonal Decomposition of Time Series by Loess with Python

I'm trying to do with Python what I the STL function on R. The R commands are fit <- stl(elecequip, s.window=5) plot(fit) How do I do this in Python? I investigated that statmodels.tsa has some time series analysis functions but I could…
user3724295
  • 193
  • 1
  • 3
  • 12
13
votes
2 answers

Time Series Ahead Prediction in Neural Network (N Point Ahead Prediction) Large Scale Iterative Training

(N=90) Point ahead Prediction using Neural Network: I am trying to predict 3 minutes ahead i.e. 180 points ahead. Because I compressed my time series data as taking the mean of every 2 points as one, I have to predict (N=90) step-ahead…
13
votes
3 answers

Multiple time series in one plot

I have a time series of several years that I need to plot in one graph. The largest series has a mean of 340 and a minimum of 245 and maximum of 900. The smallest series has a mean of 7 with a minimum of -28 and maximum of 31. The remaining series…
Meso
  • 1,375
  • 5
  • 17
  • 36
13
votes
5 answers

key-value store for time series data?

I've been using SQL Server to store historical time series data for a couple hundred thousand objects, observed about 100 times per day. I'm finding that queries (give me all values for object XYZ between time t1 and time t2) are too slow (for my…
toasteroven
  • 2,700
  • 3
  • 26
  • 35
13
votes
2 answers

Deleting a Row from a Time Indexed Dataframe

I'm trying to delete a row in a Pandas dataframe by simply passing the date and time. The dataframe has the following structure: Date_Time Price1 Price2 Price3 2012-01-01 00:00:00 63.05 41.40 …
Markus W
  • 1,451
  • 5
  • 19
  • 32