%% ======   Fit MLCM   ======
%% === Wave 3 ===
%% W3 === 2-clutsers 2-Classes MLCM ===
% Specify the parameters:
G = 31; % Number of groups
Ng= 50; % Number of subjects per group
J=10;   % Number of items
T=1;    % Number of time points
L = 2;  % Number of latent clusters 
M = 2;  % Number of latent classes   
% generate the starting values
[PH_g,PXgivenH,TauGivenH,TauGivenHT,CondResProd]=StartingValue_RandomV1(1,M,L,T,J);

[lk,iteration,G,n_g,J,L,M,est_PH_g,est_PXgivenH,est_CondResProd,Est_h,np,AIC,BIC]=...
    MLCM(ItemsT1_3D,G,Ng,L,M,J,PH_g,PXgivenH,CondResProd)
%% W3 === 2-clutsers 3-Classes MLCM ===
% Specify the parameters:
G = 31; Ng= 50; J=10; T=1;    
L = 2;  % Number of latent clusters  
M = 3;  % Number of latent classes   

% generate the starting values
[PH_g,PXgivenH,TauGivenH,TauGivenHT,CondResProd]=StartingValue_RandomV1(1,M,L,T,J);

[lk,iteration,G,n_g,J,L,M,est_PH_g,est_PXgivenH,est_CondResProd,Est_h,np,AIC,BIC]=...
    MLCM(ItemsT1_3D,G,Ng,L,M,J,PH_g,PXgivenH,CondResProd)

%% W3 === 3-clutsers 2-Classes MLCM ===
% Specify the parameters:
G = 31; Ng= 50; J=10; T=1;    
L = 3;  % Number of latent clusters  
M = 2;  % Number of latent classes   

% generate the starting values
[PH_g,PXgivenH,TauGivenH,TauGivenHT,CondResProd]=StartingValue_RandomV1(1,M,L,T,J);

[lk,iteration,G,n_g,J,L,M,est_PH_g,est_PXgivenH,est_CondResProd,Est_h,np,AIC,BIC]=...
    MLCM(ItemsT1_3D,G,Ng,L,M,J,PH_g,PXgivenH,CondResProd)

%% W3 === 3-clutsers 3-Classes MLCM ===
% Specify the parameters:
G = 31; Ng= 50; J=10; T=1;    
L = 3;  % Number of latent clusters  
M = 3;  % Number of latent classes   

% generate the starting values
[PH_g,PXgivenH,TauGivenH,TauGivenHT,CondResProd]=StartingValue_RandomV1(1,M,L,T,J);

[lk,iteration,G,n_g,J,L,M,est_PH_g,est_PXgivenH,est_CondResProd,Est_h,np,AIC,BIC]=...
    MLCM(ItemsT1_3D,G,Ng,L,M,J,PH_g,PXgivenH,CondResProd)
%% === Wave 4 ===
%% W4 === 2-clutsers 2-Classes MLCM ===
% Specify the parameters:
G = 31; Ng= 50; J=10; T=1;    
L = 2;  % Number of latent clusters 
M = 2;  % Number of latent classes   

% generate the starting values
[PH_g,PXgivenH,TauGivenH,TauGivenHT,CondResProd]=StartingValue_RandomV1(1,M,L,T,J);

[lk,iteration,G,n_g,J,L,M,est_PH_g,est_PXgivenH,est_CondResProd,Est_h,np,AIC,BIC]=...
    MLCM(ItemsT2_3D,G,Ng,L,M,J,PH_g,PXgivenH,CondResProd)

%% W4 === 2-clutsers 3-Classes MLCM ===
% Specify the parameters:
G = 31; Ng= 50; J=10; T=1;    
L = 2;  % Number of latent clusters 
M = 3;  % Number of latent classes   

% generate the starting values
[PH_g,PXgivenH,TauGivenH,TauGivenHT,CondResProd]=StartingValue_RandomV1(1,M,L,T,J);

[lk,iteration,G,n_g,J,L,M,est_PH_g,est_PXgivenH,est_CondResProd,Est_h,np,AIC,BIC]=...
    MLCM(ItemsT2_3D,G,Ng,L,M,J,PH_g,PXgivenH,CondResProd)
%% W4 === 3-clutsers 2-Classes MLCM ===
% Specify the parameters:
G = 31; Ng= 50; J=10; T=1;    
L = 3;  % Number of latent clusters 
M = 2;  % Number of latent classes   

% generate the starting values
[PH_g,PXgivenH,TauGivenH,TauGivenHT,CondResProd]=StartingValue_RandomV1(1,M,L,T,J);

[lk,iteration,G,n_g,J,L,M,est_PH_g,est_PXgivenH,est_CondResProd,Est_h,np,AIC,BIC]=...
    MLCM(ItemsT2_3D,G,Ng,L,M,J,PH_g,PXgivenH,CondResProd)
%% W4 === 3-clutsers 3-Classes MLCM ===
% Specify the parameters:
G = 31; Ng= 50; J=10; T=1;    
L = 3;  % Number of latent clusters 
M = 3;  % Number of latent classes   

% generate the starting values
[PH_g,PXgivenH,TauGivenH,TauGivenHT,CondResProd]=StartingValue_RandomV1(1,M,L,T,J);

[lk,iteration,G,n_g,J,L,M,est_PH_g,est_PXgivenH,est_CondResProd,Est_h,np,AIC,BIC]=...
    MLCM(ItemsT2_3D,G,Ng,L,M,J,PH_g,PXgivenH,CondResProd)