How to forecast a time series using exponential smoothing in R?

This recipe helps you forecast a time series using exponential smoothing in R

Recipe Objective

Exponential smoothing is a quantitative method of forecasting a time series data by using an exponential window function. In this method, the weights decrease exponentially in the exponential function. The recent values are given greater weights while the older wvalues are given lesser weights.

This method is quite intuitive and cis applied to huge range of time series data. There are many types of exponential smoothing but we are only going to discuss simple exponential smoothing in this recipe. ​

Simple Exponential smoothing technique is used when the time series data has no trend or seasonal variation. The weight of each and every parameter is always determined by alpha value described below: ​

𝐹𝑡 = 𝐹(𝑡−1) + α(𝐴(𝑡−1) – 𝐹(𝑡−1)

where:

  1. 𝐹_𝑡 =New Forecast
  2. 𝐹_(𝑡−1) = previous period forecast
  3. α = smoothing constant ( 0 ≤ α ≤ 1)
  4. 𝐴_(𝑡−1) = previous period’s actual demand

In this recipe, we will carry out simple exponential smoothing on amazon stock data ​

Get Access to Time Series Analysis Real World Projects in Python

STEP 1: Load necessary package

# for data manipulation library(tidyverse) # to get the stock data install.packages("fpp2") library(fpp2)

STEP 2: Get the google stock data

google.train = window(goog, end = 900) google.tst = window(goog, start = 901)

STEP 3: Performing Simple Exponential Smoothing

We will use the ses(train_data, alpha = , h = forecast forward steps) function to carry out the task

ses_google = ses(google.train, alpha = 0.3, # alpha value to be 0.3 h = 100) autoplot(ses_google)

What Users are saying..

profile image

Ameeruddin Mohammed

ETL (Abintio) developer at IBM
linkedin profile url

I come from a background in Marketing and Analytics and when I developed an interest in Machine Learning algorithms, I did multiple in-class courses from reputed institutions though I got good... Read More

Relevant Projects

BigMart Sales Prediction ML Project in Python
The goal of the BigMart Sales Prediction ML project is to build and evaluate different predictive models and determine the sales of each product at a store.

Abstractive Text Summarization using Transformers-BART Model
Deep Learning Project to implement an Abstractive Text Summarizer using Google's Transformers-BART Model to generate news article headlines.

Time Series Forecasting Project-Building ARIMA Model in Python
Build a time series ARIMA model in Python to forecast the use of arrival rate density to support staffing decisions at call centres.

Build a Music Recommendation Algorithm using KKBox's Dataset
Music Recommendation Project using Machine Learning - Use the KKBox dataset to predict the chances of a user listening to a song again after their very first noticeable listening event.

Predictive Analytics Project for Working Capital Optimization
In this Predictive Analytics Project, you will build a model to accurately forecast the timing of customer and supplier payments for optimizing working capital.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

Build Deep Autoencoders Model for Anomaly Detection in Python
In this deep learning project , you will build and deploy a deep autoencoders model using Flask.

Build a Multi ClassText Classification Model using Naive Bayes
Implement the Naive Bayes Algorithm to build a multi class text classification model in Python.

AWS MLOps Project to Deploy a Classification Model [Banking]
In this AWS MLOps project, you will learn how to deploy a classification model using Flask on AWS.

Build a Customer Churn Prediction Model using Decision Trees
Develop a customer churn prediction model using decision tree machine learning algorithms and data science on streaming service data.