%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%ITERATION PLOTS AND HISTOGRAMS FOR LONGITUDINAL DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%ITERATION PLOT FOR CLUSTER PROBABILITIES
%%Before copying, enter t for the desired time point t=1,...,T and j for the desired cluster j=1,...,J
t=1;                %Enter the desired time point
j=1;                %Enter the desired cluster 

eval(['plot(Theta' int2str(t) '(:,j))'])

%For iteration plots for all probabilities at time t in the same graph
t=1;
eval(['plot(Theta' int2str(t) ')'])

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%ITERATION PLOT FOR MEAN VALUES
%Before copying, enter t for desired time point t=1,...,T and j for the desired cluster j=1,...,J and K for the desired variable k=1,...,K
t=2;                 %Enter the desired time point  
j=1;                 %Enter the desired cluster 
k=1;                 %Enter the desired variable within cluster j

MTemp=[];
for i=1:T
    eval(['MTemp(i)=M' int2str(t) '(k,j,i)']);
end
plot(MTemp)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%ITERATION PLOT FOR VARIANCES OR COVARIANCES
%Before copying, enter t for desired time point t=1,...,T and j for the desired cluster j=1,...,J 
%and k1 and k2 for the desired place in the covariance matrix. k1=row and k2=column.
t=1;                 %Enter the desired time point
j=1;                 %Enter the desired cluster 
k1=1;                %Enter the desired row in the covariance matrix
k2=1;                %Enter the desired column in the covariance matrix

SigmaTemp=[];
for i=1:T
    eval(['SigmaTemp(i)=Sigma' int2str(t) '(k1,j*k1-(k1-1)+k2,i)']);
end
plot(SigmaTemp)
    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%HISTOGRAM FOR CLUSTER PROBABILITIES
%Before copying, enter t for desired time point t=1,...,T and j for
%the desired cluster j=1,...,J
t=1;                 %Enter the desired time point
j=1;                 %Enter the desired cluster 

eval(['hist(Theta' int2str(t) '(F+1:T,j))'])

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%HISTOGRAM FOR MEAN VALUES
%Before copying, enter t for desired time point t=1,...,T and j for the desired cluster j=1,...,J
%and K for the desired variable k=1,...,K
t=1;                 %Enter the desired time point
j=1;                 %Enter the desired cluster 
k=1;                 %Enter the desired variable within cluster j

MTemp=[];
for i=1:T-F
    eval(['MTemp(i)=M' int2str(t) '(k,j,F+i)']);
end
hist(MTemp)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%HISTOGRAM FOR VARIANCES OR COVARIANCES
%Before copying, enter t for desired time point t=1,...,T and j for the desired cluster j=1,...,J 
%and k1 and k2 for the desired place in the covariance matrix. k1=row and k2=column
t=1;                 %Enter the desired time point
j=1;                 %Enter the desired cluster 
k1=1;                %Enter the desired row in the covariance matrix
k2=1;                %Enter the desired column in the covariance matrix 

SigmaTemp=[];
for i=1:T-F
    eval(['SigmaTemp(i)=Sigma' int2str(t) '(k1,j*k1-(k1-1)+k2-1,F+i)']);
end
hist(SigmaTemp)
