Reputation: 11
I am trying to figure out how to combine the input and output data into the ARX model and then apply it into the BIC (Bayesian Information Criterion) formula. Below is the code that I am currently working on:
for i=1:30; %% Set Model Order
data=iddata(output,input,1);
model = arx(data,[8 9 i]);
yp = predict(model,data);
ye = regress(data,yp{1,1}(1:4018,1));
M(i) = var(yp);
BIC(i)=(N+i*(log(N)-1))/(N-i)*log(M(i));
end
But it does not work. It keeps on giving me an error that's something like below:
"The syntax "Data{...}" is not supported. Use the "getexp" command to extract individual experiments from an IDDATA object." I did not understand what does that mean. Can someone explain it to me and where do I do wrong on my piece of code?
Update: I tried to do it something like below, so far, there is no error. But then the graph for this BIC will be always straight line. Is something wrong with my regression part? how should I do for the regression?
N=length(rainfall_model);
for i=1:20; % Set Model Order
data=iddata(rainfall_model,tmax_model,1);
%d1 = getexp(data,1);
model = arx(data,[50 9 i]);
yp=predict(model,data);
y = yp.y ;
d1 = data.y ;
ye = (d1).^2 - (y).^2;
M(i)= mse(ye);
BIC(i)=(N+i*(log(N)-1))/(N-i)*log(M(i));
end
Upvotes: 1
Views: 4220
Reputation:
In your code example, yp returned from the 'predict' command is an iddata object and the cell notation '{...}' cannot be used with it. If you want to do regression, you have to extract the input (yp.u) or the output (yp.y) data from it.
Also, the command 'regress' does not work with idddata objects, since it is not a system identification toolbox function. Again you have to extract input or output data from the 'data' and 'yp' variables before calling it.
Update: To see what's in the iddata objects (data and yp), do
get(data)
get(yp)
You would see that you can extract the output data in two equivalent ways:
yp.y
yp.OutputData
Similarly, for the input data.
Upvotes: 1