annotate toolboxes/FullBNT-1.0.7/Kalman/learn_AR.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function [coef, C] = learn_AR(data, k)
wolffd@0 2 % Find the ML parameters of a vector autoregressive process of order k.
wolffd@0 3 % [coef, C] = learn_AR(k, data)
wolffd@0 4 % data{l}(:,t) = the observations at time t in sequence l
wolffd@0 5
wolffd@0 6 warning('learn_AR seems to be broken');
wolffd@0 7
wolffd@0 8 nex = length(data);
wolffd@0 9 obs = cell(1, nex);
wolffd@0 10 for l=1:nex
wolffd@0 11 obs{l} = convert_to_lagged_form(data{l}, k);
wolffd@0 12 end
wolffd@0 13
wolffd@0 14 % The initial parameter values don't matter, since this is a perfectly observable problem.
wolffd@0 15 % However, the size of F must be set correctly.
wolffd@0 16 y = data{1};
wolffd@0 17 [s T] = size(y);
wolffd@0 18 coef = rand(s,s,k);
wolffd@0 19 C = rand_psd(s);
wolffd@0 20 [F,H,Q,R,initx,initV] = AR_to_SS(coef, C, y);
wolffd@0 21
wolffd@0 22 max_iter = 1;
wolffd@0 23 fully_observed = 1;
wolffd@0 24 diagQ = 0;
wolffd@0 25 diagR = 0;
wolffd@0 26 [F, H, Q, R, initx, initV, loglik] = ...
wolffd@0 27 learn_kalman(obs, F, H, Q, R, initx, initV, max_iter, diagQ, diagR, fully_observed);
wolffd@0 28
wolffd@0 29 [coef, C] = SS_to_AR(F, Q, k);
wolffd@0 30