Blog

Using date and time variables

Posted by Michael Schmidt

28.06.2013 04:01 PM

This post describes the best way to convert date or time values into numeric time values that can be used in Eureqa.

Time Values in Eureqa:
Eureqa can only store date and time values as numeric values (e.g. total seconds or total days). Therefore, you need to pick a reference point to measure a time duration from, and units to measure the time duration.For example, you could convert a time value “8:31 am” to 8.52 total hours since midnight. Similarly for dates, you could convert a date like “Dec. 6, 1981 8:31 am” to 81.9 total years since 1900.

You need to make date and time conversions to numeric duration values in another program like Excel before entering into Eureqa (see below for example).

Pitfalls:

Pitfalls of using time variables in Eureqa
1) Do not concatenate date and time strings to get a numeric value. For example, do not convert a date like “1981-12-06” to 19811206. This representation of time is extremely nonlinear. It can preserve order, but has lost all meaning. Additionally, the values are very large and numerically unstable.

2) Avoid measuring time durations from a very distant reference point. For example, if you’re data uses time values that span a few days, do not convert these time values to total seconds since the beginning of the century. The numeric values would be enormous and numerically unstable.

Instead, the best practice is to measure a time duration since the time point in your data set.

Convert in Excel:

Many programs can convert date and time values to numeric time duration values. In Excel, if you subtract two date cells, the result is the fractional number of days between the two dates. You could then convert days to hours or some other unit to get numeric values with reasonable numeric magnitudes. For example:

    =(A0-A$0)*24

and then repeated for all rows, would subtract the first date in cell A0, and multiply the resulting day values into hours.
Another useful function is the YEARFRAC function which converts the difference between a date and a reference date to the fraction of years difference between them. For example:
    =YEARFRAC(A$0, A0)

and repeated for all rows, returns the fractional value of years from cell A0.

See Also:

Topics: Advanced Techniques, Eureqa, Preparing Data, Techniques, Time Series

Leave a Reply

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

Follow Me

Posts by Topic

see all