Research Article

# Comparison of Five Methods to Estimate the Parameters for the Three-Parameter Lindley Distribution with Application to Life Data

## Code 1

 clc clear %Number of Trials (10000). m=1;M=zeros(3,5);MSE=zeros(3,5);MAE=zeros(3,5);MRE=zeros(3,5); for j=1:m %Size of sample, theta's, alpha's and beta's Values, you can change them. P=[10 1 3 2]; %[n T A B] n=P(1); %Size of sample T=P(2); %theta A=P(3); %alpha B=P(4); %beta for i=1:n end x=round(x',4); z=sort(x); syms T A B %Initial y0=[P(2) P(3) P(4)]; %MLE S1=0;S2=0;S3=0; for i=1:n S1=S1+x(i)/n; S2=S2+log((x(i))); S3=S3+x(i)^2/n; end ; F=@(y) double(LL(y(1),y(2),y(3))); [TAB,fval,exitflag1]=fminunc(F,y0); T_ML=TAB(1); A_ML=TAB(2); B_ML=TAB(3); %OLE. S=0; for i=1:n ; end S(T,A,B)=S; F=@(y) double(S(y(1),y(2),y(3))); [TAB,fval,exitflag2]=fminunc(F,y0); T_LS=TAB(1); A_LS=TAB(2); B_LS=TAB(3); %WLS. S=0; for i=1:n ; ; end S(T,A,B)=S; F=@(y) double(S(y(1),y(2),y(3))); [TAB,fval,exitflag3]=fminunc(F,y0); T_WLS=TAB(1); A_WLS=TAB(2); B_WLS=TAB(3); %MPS syms u ; ; S=0; y(1)=0;z(n+1)=inf; for i=1:n+1. y(i+1)=z(i); D(i)=CF(y(i+1))-CF(y(i)); if D(i)==0 S=S+log(pdf(y(i))); else S=S+log(D(i)); end end S(T,A,B)=-S/(n+1); F=@(y) double(S(y(1),y(2),y(3))); [TAB,fval,exitflag4]=fminunc(F,y0); T_MPS=TAB(1); A_MPS=TAB(2); B_MPS=TAB(3); %CVM S=0; for i=1:n ; end S(T,A,B)=S+1/(n); F=@(y) double(S(y(1),y(2),y(3))); [TAB,fval,exitflag5]=fminunc(F,y0); T_CVM=TAB(1); A_CVM=TAB(2); B_CVM=TAB(3); E=[P(2) T_ML T_LS T_WLS T_MPS T_CVM;P(3) A_ML A_LS A_WLS A_MPS A_CVM;P(4) B_ML B_LS B_WLS B_MPS B_CVM];%Real MLE,OLS,WLS,MPS,CVM. E_ML=(E(:,2)-E(:,1)); E_LS=(E(:,3)-E(:,1)); E_WLS=(E(:,4)-E(:,1)); E_MPS=(E(:,5)-E(:,1)); E_CVM=(E(:,6)-E(:,1)); %if max(abs(sum(E(:,2:6),2)/5-P(:,2:4)'))=5 M=M+E(:,2:6) MSE=MSE+[E_ML E_LS E_WLS E_MPS E_CVM].^2 MAE=MAE+abs([E_ML E_LS E_WLS E_MPS E_CVM]) end end M=M/m; MSE=MSE/m; MAE=MAE/m;