I'm currently using the BSTS package with R to predict the price of a financial instrument using 20 years of hourly close data. To do this I'm starting with a simple local linear trend model (see the blog I linked for details). Here is the function I've defined that takes some vector s and returns a vector preds which is the historical out-sample predictions for s using the one.step.prediction.errors attribute of the model.

get_bsts_local_trend <- function(s){
    ss <- AddLocalLinearTrend(list(), s)

    bsts.model <- bsts(s, state.specification=ss, niter=1000)
    burn <- SuggestBurn(0.1, bsts.model)
    pred <- c(as.numeric(colMeans(bsts.model$one.step.prediction.errors[-(1:burn),])+s))

    return pred

What I found after plotting the predictions against the actuals was quite surprising. Here's a small excerpt below.

enter image description here

It seems as though the model is just using the previous actual price as it's prediction for the next hour's price + some small noise. This makes me think that I've done one of the following.

  1. The predictions I've plotted have been shifted forward one timestep accidentally. However this would indicate that the correct predictions seem too good to be true and if that's the case I then suspect I'm unintentionally using in-sample predictions or something else has gone wrong.
  2. The model has been fitted and the predictions have been calculated correctly in which case is there some sort of (preferably mathematical) logical explanation for this to occur?

Thanks in advance for any help.


1 Answer 1


What did you do before you went into using bsts neural-net method, can you tell us? Especially if you have little experience with forecasting (you did not tell), you should probably not jump directly into such modern advanced methods, but try first some simpler methods. The plot you show is rather typical ...

Forecasting tomorrow as being like today is called persistence forecasting see for instance this and search. It can be surprisingly good, many phenomena shows surprisingly much persistence, as for instance weather in the Atacama desert ... So before jumping into complex modeling, maybe make some simple baseline models, evaluate their quality (like calculate their mean square forecasting error), and later compare more complicated models to that. For some advice along this lines see for instance

and search this site!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.