Wednesday, April 14, 2021
  • Setup menu at Appearance » Menus and assign menu to Top Bar Navigation
Advertisement
  • AI Development
    • Artificial Intelligence
    • Machine Learning
    • Neural Networks
    • Learn to Code
  • Data
    • Blockchain
    • Big Data
    • Data Science
  • IT Security
    • Internet Privacy
    • Internet Security
  • Marketing
    • Digital Marketing
    • Marketing Technology
  • Technology Companies
  • Crypto News
No Result
View All Result
NikolaNews
  • AI Development
    • Artificial Intelligence
    • Machine Learning
    • Neural Networks
    • Learn to Code
  • Data
    • Blockchain
    • Big Data
    • Data Science
  • IT Security
    • Internet Privacy
    • Internet Security
  • Marketing
    • Digital Marketing
    • Marketing Technology
  • Technology Companies
  • Crypto News
No Result
View All Result
NikolaNews
No Result
View All Result
Home Data Science

Bootstrapping Time Series for Gold Rush

December 24, 2020
in Data Science
Bootstrapping Time Series for Gold Rush
585
SHARES
3.3k
VIEWS
Share on FacebookShare on Twitter

Bootstrap aggregating (bagging), is a very useful averaging method to improve accuracy and avoids overfitting, in modeling the time series. It also helps stability so that we don’t have to do Box-Cox transformation to the data.

Modeling time series data is difficult because the data are autocorrelated. In this case, moving block bootstrap (MBB) should be preferred because MBB resamples the data inside overlapping blocks to imitate the autocorrelation in the data. If the length of a time series, n, and the block size l, the number of overlapping blocks are found as below:

You might also like

6 Limitations of Desktop System That QuickBooks Hosting Helps Overcome

Robust Artificial Intelligence of Document Attestation to Ensure Identity Theft

Trends in custom software development in 2021

What we mean by overlapping block is that observation 1 to l would be block 1, observation 2 to l+1 would be block 2, etc. We should use a block size for at least two years(l=24) for monthly data because we have to be certain whether there is any remaining seasonality in the block.

From these n-l+1 blocks, n/l blocks will be selected randomly and they will be gathered in order, to build the bootstrap observations. The time series values can be repetitive in different blocks.

This bootstrap process would be exercised to the remainder component after the time series decomposition. If there is seasonality it is used the stl function(trend, seasonal, remainder) otherwise the loess function(trend, remainder) is chosen for the decomposition. It should not be forgotten that the data has to be stationary in the first place.

Box-Cox transformation is made at the beginning but back-transformed at the end of the process; as we mentioned before, when we do average all the bootstrapped series, which is called bagging, we could handle the non-stability data problem and improve accuracy compared to the original series.

As we remembered from the previous two articles, we have tried to model gold prices per gram in Turkey. We have determined the ARIMA model the best for forecasting. This time, we will try to improve using the bagging mentioned above.

In order to that, we will create a function that makes bootstrapping simulations and builds the prediction intervals we want. We will adjust the simulation number, model, and confidence level as default. We will use the assign function to make the bagged data(simfc) as a global variable, so we will able to access it outside the function as well.

library(purrr)

library(forecast)

 

sim_forecast <-  function(data, nsim=100L, h, mdl=auto.arima, level=95){

   

 

  sim <- bld.mbb.bootstrap(data, nsim)

   

  h <- as.integer(h)

  future <- matrix(0, nrow=nsim, ncol=h)

   

  future <- sim %>% map(function(x){simulate(mdl(x),nsim=h)}) %>%

    unlist() %>% matrix(ncol = h, nrow = nsim, byrow = TRUE)

   

  start < - tsp(data)[2]+1/12

   

  simfc <- structure(list(

     

    mean = future %>% colMeans() %>% ts(start = start, frequency = 12),

     

    lower = future %>% as.data.frame() %>%

      map_dbl(quantile, prob = (1-level/100)/2) %>%

      ts(start = start,frequency = 12),

     

    upper = future %>% as.data.frame() %>%

      map_dbl(quantile, prob = (1-level/100)/2+level/100) %>%

      ts(start = start,frequency = 12),

     

    level=level),

    class="forecast")

   

  assign("simfc",simfc,envir = .GlobalEnv)

   

  simfc

   

}

Because of the averaging part of the bagging, we don’t use the lambda parameter of Box-Cox transformation for the stability of the variance. We can see the forecasting results for 18 months in %95 confidence interval for training set below. We can also change the model type or confidence level if we want.

sim_forecast(train, h=18)

 

          Point Forecast    Lo 95    Hi 95

We will create the Arima model as same as we did before and compare it with a bagged version of it in a graph.

arimafc <- train %>%

  auto.arima(stepwise = FALSE,approximation = FALSE,

             seasonal = FALSE, lambda = "auto") %>%

  forecast(h=h,level=95)

 

 

autoplot(train) +

  ggtitle("Monthly Golden Price per Gram") +

  xlab("Year") + ylab("Price") +

  autolayer(test, series="Real values",PI=FALSE) +

  autolayer(simfc, series="Bagged ARIMA",PI=FALSE) +

  autolayer(arimafc, series="ARIMA",PI=FALSE)+

  theme_light()

When we examine the above plot, we can see that the bagged Arima model is smoother and more accurate compared to the classic version; but it is seen that when the forecasting horizon increases, both models are failed to capture the uptrend.

In the below, we are comparing the accuracy of models in numeric. We can easily see the difference in the accuracy level that we saw in the plot. The reason NaN values of the simulated version is that there is no estimation of fitted values(one-step forecasts) in the training set.

acc_arimafc <- arimafc %>%accuracy(test)

acc_arimafc[,c("RMSE","MAPE")]

 

 

acc_simu <- simfc %>% accuracy(test)

acc_simu[,c("RMSE","MAPE")]

 

Conclusion

When we examine the results we have found, it is seen that bootstrapping simulation with averaging (bagging) improves the accuracy significantly. Besides that, due to the simulation process, it can be very time-consuming.

The original article can be found here.


References


Credit: Data Science Central By: Selcuk Disci

Previous Post

Global Machine Learning as a Service (MLaaS) Market Report By Types, Applications, Players And Regions 2020 – The Courier

Next Post

Google Discloses Poorly-Patched, Now Unpatched, Windows 0-Day Bug

Related Posts

6 Limitations of Desktop System That QuickBooks Hosting Helps Overcome
Data Science

6 Limitations of Desktop System That QuickBooks Hosting Helps Overcome

April 13, 2021
Robust Artificial Intelligence of Document Attestation to Ensure Identity Theft
Data Science

Robust Artificial Intelligence of Document Attestation to Ensure Identity Theft

April 13, 2021
Trends in custom software development in 2021
Data Science

Trends in custom software development in 2021

April 13, 2021
Epoch and Map of the Energy Transition through the Consensus Validator
Data Science

Epoch and Map of the Energy Transition through the Consensus Validator

April 13, 2021
NetSuite ERP ushering a digital era for SMEs
Data Science

NetSuite ERP ushering a digital era for SMEs

April 12, 2021
Next Post
Google Discloses Poorly-Patched, Now Unpatched, Windows 0-Day Bug

Google Discloses Poorly-Patched, Now Unpatched, Windows 0-Day Bug

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended

Plasticity in Deep Learning: Dynamic Adaptations for AI Self-Driving Cars

Plasticity in Deep Learning: Dynamic Adaptations for AI Self-Driving Cars

January 6, 2019
Microsoft, Google Use Artificial Intelligence to Fight Hackers

Microsoft, Google Use Artificial Intelligence to Fight Hackers

January 6, 2019

Categories

  • Artificial Intelligence
  • Big Data
  • Blockchain
  • Crypto News
  • Data Science
  • Digital Marketing
  • Internet Privacy
  • Internet Security
  • Learn to Code
  • Machine Learning
  • Marketing Technology
  • Neural Networks
  • Technology Companies

Don't miss it

Apache Software Foundation retires slew of Hadoop-related projects
Big Data

Apache Software Foundation retires slew of Hadoop-related projects

April 14, 2021
Coinbase IPO marks historic first crypto company to enter US stock exchange as Bitcoin rockets
Blockchain

Coinbase IPO marks historic first crypto company to enter US stock exchange as Bitcoin rockets

April 13, 2021
AI.Reverie Appoints Former NVIDIA Deep Learning Guru Aayush Prakash as Head of Machine Learning
Machine Learning

AI.Reverie Appoints Former NVIDIA Deep Learning Guru Aayush Prakash as Head of Machine Learning

April 13, 2021
Music and Artificial Intelligence | by Ryan M. Raiker, MBA | Apr, 2021
Neural Networks

Music and Artificial Intelligence | by Ryan M. Raiker, MBA | Apr, 2021

April 13, 2021
The rise of headless and hybrid CMS: Tuesday’s daily brief
Digital Marketing

The rise of headless and hybrid CMS: Tuesday’s daily brief

April 13, 2021
Brave browser disables Google’s FLoC tracking system
Internet Security

Brave browser disables Google’s FLoC tracking system

April 13, 2021
NikolaNews

NikolaNews.com is an online News Portal which aims to share news about blockchain, AI, Big Data, and Data Privacy and more!

What’s New Here?

  • Apache Software Foundation retires slew of Hadoop-related projects April 14, 2021
  • Coinbase IPO marks historic first crypto company to enter US stock exchange as Bitcoin rockets April 13, 2021
  • AI.Reverie Appoints Former NVIDIA Deep Learning Guru Aayush Prakash as Head of Machine Learning April 13, 2021
  • Music and Artificial Intelligence | by Ryan M. Raiker, MBA | Apr, 2021 April 13, 2021

Subscribe to get more!

© 2019 NikolaNews.com - Global Tech Updates

No Result
View All Result
  • AI Development
    • Artificial Intelligence
    • Machine Learning
    • Neural Networks
    • Learn to Code
  • Data
    • Blockchain
    • Big Data
    • Data Science
  • IT Security
    • Internet Privacy
    • Internet Security
  • Marketing
    • Digital Marketing
    • Marketing Technology
  • Technology Companies
  • Crypto News

© 2019 NikolaNews.com - Global Tech Updates