clc;clear;

numberstates = 5;
numberobs = 8;

load '.\datasets\\lp_ragged\default.mat';
default = mat2cellrmNaNs(data);

%preallocate space for arrays

transition_guess = zeros(numberstates,numberstates);
obs_guess = zeros(numberstates,numberobs);

transition_guess =...
    [1 0 0 0 0;...          %state1
    .25 .25 .25 .20 .05;...   %state2
    .20 .20 .20 .20 .20;...     %state3
    .05 .20 .25 .25 .25;...       %state4
    0 0 0 0 1];             	%state5

obs_guess =...
    [0 0 0 0 0 0 0 1;...
    .80 .10 .05 .02 .015 .015 0 0;...
    .10 .20 .30 .30 .05 .05 0 0;...
    .015 .015 .02 .05 .10 .80 0 0;...
    0 0 0 0 0 0 1 0];

% transition_guess =...
%     [.998 .0005 .0005 .0005 .0005;...           %state1
%     .25 .25 .25 .20 .05;...                     %state2
%     .20 .20 .20 .20 .20;...                     %state3
%     .05 .20 .15 .35 .25;...                     %state4
%     .0025 .0025 .0025 .0025 .99];               %state5
% 
% obs_guess =...
%     [1.4286e-004 1.4286e-004 1.4286e-004 1.4286e-004 1.4286e-004 1.4286e-004 1.4286e-004 .999;...
%     .80 .10 .05 .02 .015 .015 0 0;...
%     .10 .20 .30 .30 .05 .05 0 0;...
%     .015 .015 .02 .05 .10 .80 0 0;...
%     1.4286e-004 1.4286e-004 1.4286e-004 1.4286e-004 1.4286e-004 1.4286e-004 .999 1.4286e-004];

%change intial state distribution (all loans start in state 2)
p = [2.5e-004 .999 2.5e-004 2.5e-004 2.5e-004]
transition_guess_hat = [0 p; zeros(size(transition_guess,1),1) transition_guess];
obs_guess_hat = [zeros(1,size(obs_guess,2)); obs_guess];

 [defaulttrans defaultemis] = hmmtrain(default,transition_guess_hat,obs_guess_hat,...
     'verbose',true)

% [paidtrans paidemis] = hmmtrain(paid(1:2000,:),transition_guess_hat,obs_guess_hat,...
%     'verbose',true)


    
    
    
