Tutorial 3 - Time series

In this tutorial we will build a simple model from multivariate time series data.

The data consists of a single time series over the two continuous variables X1 and X2. A chart of X1 and X2 is shown below.

The following concepts will be covered:

Time series walkthrough X1, X2 chart

NOTE

Bayes Server must be installed, before starting this tutorial. An evaluation version can be downloaded from the Downloads page

Companion video (No Audio)

Creating the model

We will create the simple Dynamic Bayesian network shown below.

Time series DBN

Add the nodes

NOTE

Note that we could have added the nodes automatically using the Add nodes from data feature.

NOTE

You can either evaluate a time series model on unseen data with different Temporal orders to determine the best model, or you can use Structural learning.

NOTE

To understand the structure of a Dynamic Bayesian network, click the Unroll button on the Network tab, Refactoring group, to see what the equivalent Bayesian network would look like. Note that unrolling is not required to work with Dynamic Bayesian networks.

Learning the distributions

We could now enter the distribution parameters for the nodes manually using the Distribution editor, however in this tutorial we will learn the parameter values from data.

For convenience, we will use Microsoft Excel as the data source, however another database can be substituted.

Adding a data connection

NOTE

Note: You can skip this step, and instead use the pre-installed Tutorial data connection (Walkthrough Data in earlier versions).

Parameter learning

NOTE

Using a Case Id column in this example is optional as we only have a single multivariate time series.

Time Series Prediction

Enter evidence

Before predicting future values, we will enter some evidence.

NOTE

You can enter evidence manually using the Evidence window, however we will use Data Explorer here for convenience.

Time Series Query

Time Time Type
Min 1 Relative
Max 25 Relative
NOTE

Relative means that times starts from the maximum evidence time.

NOTE

You can also plot a custom time series predictions from the Query tab, Temporal group

Time series - Toggle chart display type

The network should look like this:

Time series - prediction

More complex models

The network created in this tutorial can be extended by adding additional nodes, to model more complex data.

For example, discrete nodes could be added, that represent different regimes/contexts, allowing the Gaussian distributions to vary. This could be a node that is mapped to data, or a latent (cluster) variable, similar to that used in Tutorial 2 - Mixture model however is typically a temporal node.

Data

Case Time X1 X2
0 0 2.318745783 20.46006463
0 1 5.933818502 17.67586928
0 2 7.504462149 15.1712915
0 3 8.851967996 13.46621753
0 4 12.60817163 12.45778021
0 5 13.53426343 11.28238594
0 6 14.08388741 11.36542721
0 7 13.3766438 11.32797101
0 8 15.68526939 10.8970169
0 9 15.11022927 14.1524426
0 10 13.20119013 14.26016682
0 11 9.494001085 16.08702792
0 12 8.304703769 18.63487888
0 13 6.593647849 22.21299995
0 14 4.118074113 23.21864609
0 15 2.111678085 26.50607334
0 16 2.476215264 26.69056302
0 17 -0.231077926 28.01168052
0 18 0.087771397 30.26062659
0 19 1.315852301 29.6079087
0 20 2.810231967 30.05485261
0 21 2.552855638 26.86816415
0 22 4.900436683 25.76875809
0 23 7.913171459 23.26273577
0 24 9.737370988 21.25918873
0 25 12.66258445 19.13469172
0 26 15.64544348 15.71762796
0 27 20.58203988 15.42579064
0 28 22.86777997 10.63982879
0 29 23.57926162 10.27021685
0 30 27.02910891 9.817333981
0 31 25.58107867 9.061899103
0 32 26.94255966 9.584602154
0 33 27.16040423 9.442765674
0 34 27.04495789 10.51641975
0 35 24.90688221 11.75130635
0 36 23.98954889 14.35173433
0 37 22.28610935 16.40809747
0 38 19.78816701 17.39167485
0 39 16.91941516 19.96761072
0 40 17.29332335 22.57813982
0 41 14.01409456 24.24254295
0 42 13.87122505 25.42334936
0 43 13.44463368 27.31677309
0 44 14.83781008 26.23227138
0 45 15.68276374 26.56970664
0 46 15.13583588 27.03137041
0 47 16.43886985 25.07092718
0 48 20.7979978 21.18958008
0 49 23.48791794 20.8674994
0 50 26.72710284 18.26751923
0 51 30.28903693 15.61215805
0 52 30.51520286 13.53912436
0 53 35.46528278 10.30766893
0 54 37.84679647 9.496972103
0 55 38.08298043 6.199712849
0 56 40.39095686 5.590196774
0 57 40.07846242 6.959696004
0 58 40.08610277 7.152498131
0 59 40.05179382 6.732313676
0 60 38.15557619 10.37673309
0 61 34.99846217 10.03214111
0 62 34.6842111 13.81602026
0 63 31.58501235 14.62634965
0 64 29.21931264 18.37806697
0 65 28.79983427 19.48749404
0 66 27.62649704 22.95728553
0 67 24.91441719 21.98144367
0 68 27.14508364 23.12311523
0 69 26.36169102 25.70715991
0 70 25.42262786 22.91309475
0 71 26.68629076 24.76868418
0 72 29.69233279 21.08297546
0 73 30.99710698 19.63166555
0 74 34.02657121 19.00319207
0 75 39.27729696 13.73228031
0 76 39.67147284 11.96785476
0 77 44.18986124 10.81560819
0 78 45.904526 7.002139952
0 79 49.52983788 5.68254081
0 80 51.30622996 4.286459901
0 81 50.67634617 4.42147376
0 82 53.11851589 3.747526155
0 83 51.48325685 3.070023993
0 84 50.63623668 4.0580626
0 85 51.8926161 5.507954661
0 86 48.70427797 9.596489359
0 87 47.51607953 11.35891616
0 88 46.67047755 13.64482398
0 89 43.05034733 15.68684769
0 90 41.62091455 17.72461027
0 91 39.80023298 19.58704864
0 92 39.29655794 20.00115014
0 93 38.93020152 23.13560737
0 94 38.88239321 21.07024372
0 95 39.63691083 22.20872048
0 96 40.17065414 21.28034691
0 97 42.31931906 20.13211517
0 98 43.81657518 17.76721478
0 99 48.32749664 15.14488814