Coder Social home page Coder Social logo

bststest's Introduction

bstsTest

Rapidly Test BSTS Models in R

Installation

require(devtools)
devtools::install_github('lissahyacinth/bstsTest')

Usage

set.seed(10)
library(bstsTest)
library(data.table)

bstsData <- melt(
                    data.table("London" = ts(rnorm(100) + 10,frequency = 7, start = Sys.Date()), 
                    "France" =  ts(rnorm(100) + 5,frequency = 7, start = Sys.Date()), 
                    "Manchester" =  ts(rnorm(100) +2,frequency = 7, start = Sys.Date()), 
                   "Date" = as.Date(1:100, origin = "2001-01-01")),
               measure.vars = c("London", "France", "Manchester"),
               variable.name = "City",
               value.name = "Sessions")

x = bsts_test(df = bstsData, 
              date_variable = "Date", 
              validate_n = 14, 
              na_fill = 0,
              model.options = bsts::BstsOptions(),
              response = "London", 
              group_variable = "City", 
              target_variable = "Sessions",
              nseasons = 28,
              niter = 1000,
              rebag_vars = T,
              rebag_mean_vars = T,
              inclusion_probability = 0.1)

# Mean Absolute Percentage Error and Root Mean Square Error are now visible on a 14 day cross validation. 
x$MAPE
> 0.12
x$RMSE
> 1.438

Features

Rebag is a way of aggregating small predictors into one big predictor. It's sometimes helpful, and sometimes a hinderance when there's strong correlation between rebag and some of your core predictors. It's likely to get an exclusion list at some point in the future when you need to test just some predictors. Rebag comes in two forms - the aggregate sum, and the mean - I found adding the mean weakens the test case, but it can have some applications.

Auto can be specified for nseasons instead of providing a seasonality. I find this works relatively well for rapid iteration testing, but is no replacement for actually calculating the seasonality yourself.

bststest's People

Contributors

lissahyacinth avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.