%% ======   Fit MLMM   ======
%% === 2-clutsers 2-Classes MLMM ===
% Specify the parameters:
G = 31; % Number of groups
Ng= 50; % Number of subjects per group
J=10;   % Number of items
T=2;    % 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);

%  Fit the MLMM 
[lk,iteration,G,Ng,J,T,L,M,PH_g,PXgivenH,TauGivenH,CondResProd,Est_h,np,AIC,BIC]=...
    MLMM(Data4D,Data2D,G,Ng,L,M,J,T,PH_g,PXgivenH,TauGivenH,CondResProd)
%% === 2-clutsers 3-Classes MLMM ===
% Specify the parameters:
G = 31; Ng= 50; J=10;  T=2;
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);

%  Fit the MLMM 
[lk,iteration,G,Ng,J,T,L,M,PH_g,PXgivenH,TauGivenH,CondResProd,Est_h,np,AIC,BIC]=...
    MLMM(Data4D,Data2D,G,Ng,L,M,J,T,PH_g,PXgivenH,TauGivenH,CondResProd)

%% === 3-clutsers 2-Classes MLMM ===
% Specify the parameters:
G = 31; Ng= 50; J=10;  T=2;
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);

%  Fit the MLMM 
[lk,iteration,G,Ng,J,T,L,M,PH_g,PXgivenH,TauGivenH,CondResProd,Est_h,np,AIC,BIC]=...
    MLMM(Data4D,Data2D,G,Ng,L,M,J,T,PH_g,PXgivenH,TauGivenH,CondResProd)

%% === 3-clutsers 3-Classes MLMM ===
% Specify the parameters:
G = 31; Ng= 50; J=10;  T=2;
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);

%  Fit the MLMM 
[lk,iteration,G,Ng,J,T,L,M,PH_g,PXgivenH,TauGivenH,CondResProd,Est_h,np,AIC,BIC]=...
    MLMM(Data4D,Data2D,G,Ng,L,M,J,T,PH_g,PXgivenH,TauGivenH,CondResProd)
