% test armle.m

T = 500;
a = [0.9];
b = [0.5 0.2]'; % MA coefficients
sigma = 1;

% Simulate data
n = 100;
X = zeros(n+T,1);
X(1) = 0;
p = length(a);
q = length(b);
e = normrnd(0,sigma,n+T+q,1);
for i = 2:T+n
    X(i) = e(i+q) + a'*X(i-1) + b'*e(i+q-1:-1:i);
end

%X = X(n+1:n+T);

%figure(3), plot(X)
% Estimate MA(1) Model
theta0 = [0.5 0.4 0.3 0.8 0.1]';
[theta,se,logl] = armamle(X,theta0,p);

% Display results
theta_true = [a' b' sigma 0]';
disp('Model Estimates')
disp([theta_true theta se])
