Daniel@0: function [coef, C] = learn_AR(data, k) Daniel@0: % Find the ML parameters of a vector autoregressive process of order k. Daniel@0: % [coef, C] = learn_AR(k, data) Daniel@0: % data{l}(:,t) = the observations at time t in sequence l Daniel@0: Daniel@0: warning('learn_AR seems to be broken'); Daniel@0: Daniel@0: nex = length(data); Daniel@0: obs = cell(1, nex); Daniel@0: for l=1:nex Daniel@0: obs{l} = convert_to_lagged_form(data{l}, k); Daniel@0: end Daniel@0: Daniel@0: % The initial parameter values don't matter, since this is a perfectly observable problem. Daniel@0: % However, the size of F must be set correctly. Daniel@0: y = data{1}; Daniel@0: [s T] = size(y); Daniel@0: coef = rand(s,s,k); Daniel@0: C = rand_psd(s); Daniel@0: [F,H,Q,R,initx,initV] = AR_to_SS(coef, C, y); Daniel@0: Daniel@0: max_iter = 1; Daniel@0: fully_observed = 1; Daniel@0: diagQ = 0; Daniel@0: diagR = 0; Daniel@0: [F, H, Q, R, initx, initV, loglik] = ... Daniel@0: learn_kalman(obs, F, H, Q, R, initx, initV, max_iter, diagQ, diagR, fully_observed); Daniel@0: Daniel@0: [coef, C] = SS_to_AR(F, Q, k); Daniel@0: