Back

A Practical Introduction to Time Series Analysis

Created 1 year ago
29 Views
0 Comments
Dhananjay3oiW5R
@Dhananjay3oiW5R
Dhananjay3oiW5R
@Dhananjay3oiW5RProfile is locked. Login

Time series analysis is a statistical method used to examine and model time-dependent data. It involves analyzing patterns, trends and relationships within time-stamped data, to understand and make predictions about future events. Time series data can come from a variety of sources, including financial markets, economic indicators, weather patterns, and consumer behavior. Key techniques used in time series analysis include trend analysis, seasonality analysis, and forecasting models such as ARIMA and Exponential Smoothing.


A simple way to explain the Time series would be.


Analyzing time series is similar to predicting what will happen next in a novel. Consider reading a book and keeping a daily journal of what happens. You can begin to see trends in the narrative after a while, such as the same type of event occurring every Monday. This is similar to time series analysis, in which you examine a number of past occurrences to try to predict the future.

Some of the most Important techniques used Time series Analysis would be.


Moving Average Point:


Moving average in time series analysis is a statistical method used to calculate the average value of a set of data over a specified time period. The average is calculated by taking the sum of the data points in the set and dividing by the number of points.[1]


Moving average is used in time series analysis to:


->Smooth out short-term fluctuations and highlight long-term trends.


->Remove noise and reduce volatility.


->Make the data easier to visualize and interpret.


A simple moving average point can be calculated as the average of a set of consecutive data points, such as stock prices over a set number of days. For example, if the stock prices for the past 7 days were [100, 95, 98, 102, 101, 97, 104], the moving average point for day 7 would be 100 (the average of all 7 prices).


Let us visualize with a code:

#importing the Lib
import matplotlib.pyplot as plt
import numpy as np
arr = [1,-7000,-3456,-2000,-100,-4000,100,69,1234,3748,-3000,-2100,6700,111,123,1245,6489]#sample Stock Market value
#creating time series Stamp to values. 
l1=[]
for i in range(0,len(arr)):
    l1.append(i)
window_size = 4#this denotes the number of value for which an averge is generated. 
i = 0
# Movinhg averge point
moving_averages = []
while i < len(arr) - window_size + 1:#this loop is used to calculet the averages with in the given window.
    window_average = round(np.sum(arr[
      i:i+window_size]) / window_size, 2)
    moving_averages.append(window_average)# the data is added the a new array.
    i += 1
#Plotting the graphs. 
plt.subplot(1, 2, 1) # row 1, col 2 index 1
plt.title("Normal Graph")
plt.plot(l1,arr, color="red")
plt.xlabel('Time series')
plt.ylabel('Stock Value')
l1=[]
for i in range(0,len(moving_averages)):
    l1.append(i)
plt.subplot(1, 2, 2) # index 2
plt.plot(l1,moving_averages)
plt.title("Graph with Moving Average")
plt.xlabel('Time series')
plt.ylabel('Stock Value')
plt.show()


Reference:

[1]Time series and moving averages | ACCA Global

Comments
Please login to comment.