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

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function [coef, C] = learn_AR(data, k)
Daniel@0 2 % Find the ML parameters of a vector autoregressive process of order k.
Daniel@0 3 % [coef, C] = learn_AR(k, data)
Daniel@0 4 % data{l}(:,t) = the observations at time t in sequence l
Daniel@0 5
Daniel@0 6 warning('learn_AR seems to be broken');
Daniel@0 7
Daniel@0 8 nex = length(data);
Daniel@0 9 obs = cell(1, nex);
Daniel@0 10 for l=1:nex
Daniel@0 11 obs{l} = convert_to_lagged_form(data{l}, k);
Daniel@0 12 end
Daniel@0 13
Daniel@0 14 % The initial parameter values don't matter, since this is a perfectly observable problem.
Daniel@0 15 % However, the size of F must be set correctly.
Daniel@0 16 y = data{1};
Daniel@0 17 [s T] = size(y);
Daniel@0 18 coef = rand(s,s,k);
Daniel@0 19 C = rand_psd(s);
Daniel@0 20 [F,H,Q,R,initx,initV] = AR_to_SS(coef, C, y);
Daniel@0 21
Daniel@0 22 max_iter = 1;
Daniel@0 23 fully_observed = 1;
Daniel@0 24 diagQ = 0;
Daniel@0 25 diagR = 0;
Daniel@0 26 [F, H, Q, R, initx, initV, loglik] = ...
Daniel@0 27 learn_kalman(obs, F, H, Q, R, initx, initV, max_iter, diagQ, diagR, fully_observed);
Daniel@0 28
Daniel@0 29 [coef, C] = SS_to_AR(F, Q, k);
Daniel@0 30