3

I'm trying to build an ARMAX model which predicts reservoir water elevation as a function of previous elevations and an upstream inflow. My data is on a timestep of roughly 0.041 days, but it does vary slightly, and I have 3643 time series points. I've tried using the basic armax Matlab command, but am getting this error:

Error using armax (line 90)
Operands to the || and && operators must be convertible to
logical scalar values.

The code I'm trying is:

data = iddata(y,x,[],'SamplingInstants',JDAYs)
m1 = armax(data, [30 30 30 1])

where y is a vector of elevations that starts like y=[135.780 135.800 135.810 135.820 135.820 135.830]', x is a vector of flowrates that starts like x=[238.865 238.411 238.033 237.223 237.223 233.828]', and JDAYs is a vector of timestamps that starts like JDAYs=[122.604 122.651 122.688 122.729 122.771 122.813]'.

I'm new to this model type and the system identification toolbox, so I'm having issues figuring out what's causing that error. The Matlab examples aren't very helpful...

Amy
  • 183
  • 3
  • 16

1 Answers1

2

I hope this is not getting to you a bit late.

Checking your code i see that you are using a parameter called SamplingInstants. I'm not sure ARMAX functions works with it. Actually i'm sure. I have tried several times, and no, it doesn't. And it don't seems to be a well documented option for ARMAX -or for other methods- too.

The ARX, ARMAX, and other models are based on linear discrete systems from the Z-Transform formalism, that is, one can ussualy assume that your system has been sampled under a regular sampling rate. Although of course, this is not a law, this is the standard framework when dealing with linear -and also non-linear- systems. And also most industrial control & acquisition systems work under a regular rate sampling. Yet.

Try to get inside the ARMAX standard setting, like this:

y=[135.780 135.800 135.810 135.820 135.820 135.830 .....]';
x=[238.865 238.411 238.033 237.223 237.223 233.828 .....]';
%JDAYs=[122.604 122.651 122.688 122.729 122.771 122.813 .....]';
JDAYs=122.601+[0:length(y)-1]*4.18';
data = iddata(y,x,[],'SamplingInstants',JDAYs);
m1 = armax(data, [30 30 30 1])

And this will always work. Please just ensure that x and y are long enough to enable the proper estimation of all the free coefficients, greater than mean(4*orders), for ARMAX to work -in this case, greater than 121-, and desirable greater than 10*mean(4*orders), for ARMAX algorithm to properly solve your problem, and enough time-variant for prevent reaching onto ill-conditioned solutions.

Good Luck ;)...

Brethlosze
  • 1,533
  • 1
  • 22
  • 41
  • 1
    I know this comes a long time after, but I am interested in your last paragraph. I am currently using ARX/ARMAX models in another problem. Could you elaborate it? Do you mean that one should keep orders small to avoid overestimation? – titus.andronicus Feb 23 '15 at 13:38
  • Yes. This is matter of how much available accuracy do you have for solving the parameter estimation problem. If you have 1000 points, and you want to estimate 1 parameters, the deterministic 1-th estimation error will be equal to `e(n)=rms(y-ye(p(n)))`, the stochastic prediction error will be `se(n)=std(y-ye(p(n)))` and the parameter expected error -by considering `p` as a stochastic variable by iterating on the experiment frame `i`, will be equal to `sp(n)=std(p(n)-mean(p(n)))`. – Brethlosze Mar 15 '15 at 22:43
  • When increasing the dimension of `p`, `e` decreases and `se` increases when approaching the optimal setting for `n`, the dimension of `p`. When `n`=1, both `e` and `se` are nonzero, and on the limit when `n` tends to infinity, `e` is zero, and `se` tends to `std(y)` (or some nonzero value). Hence, 'assuming' continuity -this is, assuming the data is able to be fitted under the model you are constraining-, there 'exists' an optimal for the `n` parameter. The condition of continuity on the stochastic variables `se(n)` and `e(n)` is very often ignored and is ussualy a matter of 'assumption'. – Brethlosze Mar 15 '15 at 22:43