function [mbest,minaic,pbest,qbest]=armabat(x,pvec,qvec)
%
% [mbest,minaic,pbest,qbest]=armabat(x,pvec,qvec)
%
% This functions computes ARMA (p,q) models for
% (p,q) in (pvec x qvec ); it returns the best according to AIC
% where AIC has been modified to account for fixed parameters
%
% x = input data
% pvec = vector of p's ; set pvec=[0] for no AR
% qvec = vector of q's; set qvec=0[] for no MA
% mbest = matlab model structure for the best one found using the matlab aic
% the model parameters can be retreived from mbest
% minaic = value of the aic at the min
% pbest = best value of p found
% qbest = best value of q found
% now estimate ARMA model; ARMAX is AX=BU + Ce so identify phi with A and theta with C
nx=length(x);