1
$\begingroup$

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

$\endgroup$
7
  • $\begingroup$ For LinearModelFit[data,x,x] the data should be {{time, variable},{time2, variable2},...} so you need to manipulate data initially $\endgroup$ Commented Sep 23, 2016 at 16:28
  • 3
    $\begingroup$ 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. $\endgroup$ Commented Sep 23, 2016 at 16:49
  • $\begingroup$ 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 $\endgroup$ Commented Sep 23, 2016 at 20:02
  • $\begingroup$ @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. $\endgroup$ Commented Sep 23, 2016 at 21:20
  • $\begingroup$ @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 $\endgroup$ Commented Sep 24, 2016 at 10:23

1 Answer 1

1
$\begingroup$

Comments are right. I have to convert time to seconds. What I did was to use the code provided by @kglr in this question Converting timestamps into a decimal in minutes

Thanks to EE!

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.