# How to LinearModelFit data like {{year,month,day,hour,minute,second,variable}}?

As the title says...I have my data in the form :

{{year,month,day,hour,minute,second,variable},{year,month,day,hour2,minute2,second2,variable}, ...}

LinearModelFit[data,x,x] does not work :P (I am new to Mathematica, so any pointers will be appreciated)

Thanks

• For LinearModelFit[data,x,x] the data should be {{time, variable},{time2, variable2},...} so you need to manipulate data initially – Coolwater Sep 23 '16 at 16:28
• If not going for TimeSeriesModelFit in this case, I would use AbsoluteTime[{y,m,d,h,m,s}] to convert the times. You may then use Standardize[ {absTime1, absTime2, ...}, First, 1&] to shift the times to start with 0. – gwr Sep 23 '16 at 16:49
• LinearModelFit[data,x,x] won't work because the number of columns in data is greater than the number of regressors (x). If you want to make this work, then you should use something like lmf=LinearModelFit[data, {x1,x2,x3,x4,x5,x6}, {x1,x2,x3,x4,x5,x6}]. Also note how your regression will contain a constant term. If you don't want that, you should include the option _IncludeConstantBasis_->False – user42582 Sep 23 '16 at 20:02
• @user42582 It will work because the values encoding time can be compared to representing a number by its digits. In the end it simply is a single value. – gwr Sep 23 '16 at 21:20
• @gwr: the question presents a design matrix with 6 independent vars. LinearModelFit[data,x,x] will report an error when evaluated. Note, that the input data are already date/time components. The fact that you interpret the question as a request for providing - in addition to making the given code work - a way to acquire a date/time time-stamp is something that is not asked. As a side note, in my previous comment I said that the LinearModelFit[data,x,x] wouldn't work, not that your version wouldn't work. The fact is that using AbsoluteTime[]is not relevant in the present context – user42582 Sep 24 '16 at 10:23