# Quantify time until warning for forecasting, getting the start time of a capsule

Go to solution Solved by Thorsten Vogt,

## Recommended Posts

Hello.

I am trying to perform some forecasting for a signal, which only becomes active whenever it's derivative goes above a high threshold. I have built two OILS models based on the formula regressionModelOLS() for this. One model is linear and one is 2nd degree polynomial. I am now trying to validate that they work, so I've shifted forward my signal to the critical event where they would start to forecast, which is a re-occuring seasonal event happening one time per year. These models forecast over a horizon of one week, and the at the critical event it looks like this:

I am very satisfied with this result, and it performs as I would like to with the fitting.

The next thing I would like to do is to quantify the time from now until the warning capsules occur, which you see in the capsule tab at the bottom right. How do I calculate the time from now() until the “Poly warning” at 9 AM on Aug 18, or the “Linear warning” at 5 PM on Aug 19? This needs to be some dynamic type of measurement, as these conditions will move in time when the models become re-fitted as the data becomes updated. It's best if I could get this time difference in d:hh:mm format if possible, to precisely know how long left the forecasting predicts the warning levels to be breached.

I've experiemented using the Timesince() function a little bit, but it doesn't give me any result at the moment.

Some ideas/help would be greatly appreciated, thanks!

##### Share on other sites

• Solution

Hi Joel,

you can try the following formula to create a capsule from now to the capsule in the future:

```condition(1d, capsule(now(), now()+1s))
.join(\$warning, 10d) - \$warning```

Regards,

Thorsten

• 1
##### Share on other sites

Thank you Thorsten, you are a magician!