1
$\begingroup$

I have 6 sequences (time series); they all belong to the same variable. I divide each sequence in two parts having 80% and leaving the last 20% for validation. I am doing the analysis and modelling in Matlab.

In the training set (80%):
I want to train on 5 sequences using an autoregressive method having a window size of 1 event in order to model the behaviour of the sequences (e.g. sequences 2:5 = $X$) and see whether I can predict the one that is left out (e.g. sequence 1 = $Y$).

I want to have the model learning by steps. The dependency would be like $$ Y_n = \text{sd}(X_{n-1}) + \text{mean}(X_{n-1}) $$

For this I am thinking of using the Matlab function arima to estimate the model parameters. I don’t know though how to integrate the modelling of $X$ in arima since the estimation seems to be for $Y$.
Q1: Maybe I am not understanding well how to use this?

I assume an alternative would be using fitlm to obtain the model between the mean and standard deviation (of all the sequences in the training set) per event in $X_{n-1}$ and the sequence in $Y_n$.

Q2: Which of these both methods would be better to take into account the changes from event to event?

In the testing set (20%):
Once I have the model I would like to use it to test its accuracy on the 20% percent left. I understand that when using fitlm the best would be to use predict or feval and for arima I should use forecast.
Q3: Is this correct?

Q4: Can anyone point me some simple example or tutorial on how to do this correctly?

$\endgroup$

1 Answer 1

1
$\begingroup$

This is not an autoregressive model. Autoregressive series would have $X_n(t)=\dots \theta_1 X_n(t-1)$ terms, while yours seem to have only $X_n(t)=\dots \theta_1 X_{k\ne n}(t-1)$.

Hence, yours is a simple cross-sectional model. Here how it looks: $$y=\beta_0+\beta_1 x_1 + \beta_2 x_2$$

All you need is to create two new variables: $x_1,x_2$. The first one is the StDev of the other four (five?) series, and the second one is the mean. So, you have

y = x(2:end,1)
temp = x(1:end-1,2:5);
X = [std(temp,0,2) mean(temp,0,2)]
mdl = fitlm(y,X)

That's it. Once you have the model object you can use its predict function and other methods to get what you want. Read fitlm's help, it has examples.

$\endgroup$
4
  • $\begingroup$ Thanks, I explained something wrong I believe. In my case it would be: X = [std(temp') mean(temp')] $\endgroup$
    – Noque
    Feb 3, 2016 at 21:28
  • $\begingroup$ @Noque my bad, I fixed the code. Your explanation was not incorrect. What you need is a std or mean across the sequences, my code had a bug. $\endgroup$
    – Aksakal
    Feb 3, 2016 at 22:42
  • $\begingroup$ Thanks, I think there is another bug fitlm should have the arguments reversed. That is fitlm(X,y) $\endgroup$
    – Noque
    Feb 4, 2016 at 15:22
  • $\begingroup$ @Noque, sorry, you might be right, I don't remember exact syntax $\endgroup$
    – Aksakal
    Feb 4, 2016 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.