Calculating bias and the mean squared error fails?

We need help for solve a problem to calculate bias and the mean sequer error

f[x, \[Mu], \[Sigma], \[Lambda]1, \[Lambda]2] = (1/\[Sigma]) E^-((
      x - \[Mu])/\[Sigma] + 
      E^-((x - \[Mu])/\[Sigma])) (1 + \[Lambda]1 + 
     2 ( \[Lambda]2 - \[Lambda]1) E^(- 
        E^-((x - \[Mu])/\[Sigma]))     - 
     3 \[Lambda]2  E^(- 2 E^-((x - \[Mu])/\[Sigma]))  );

dist = ProbabilityDistribution[
   f[x, \[Mu], \[Sigma], \[Lambda]1, \[Lambda]2], {x, 0, \[Infinity]}];
init = {\[Mu] \[RightArrow] 3, \[Sigma] \[RightArrow] 
    2, \[Lambda]1 \[RightArrow] 0.5, \[Lambda]2 \[RightArrow] 0.5};
disGen = dist /. init;
m = 100; n = 1000
data = RandomVariate[distGen, {m, n}]
MSE = 0; bias = 0;
sum = ConstantArray[0, Length[ dist]]
sum
Do[res = FindDistributionParameters[data[[i]], 
    ProbabilityDistribution, 
    ParameterEstimator -> "MaximumLikelihood"];
  MSE += (res - Values[init])^2 /. Rule \[RightArrow] List;
  sum += res /. Rule \[RightArrow] List;
  bias += Abs[res - Values[init]] /. Rule \[RightArrow] list, {i, 1, 
   m}];

pdf.nb (24.9 KB)

It is syntax. You are using \[RightArrow] instead of \[Rule]. It looks very similar, but it has a different interpretation.

Thanks, but the problem is still there.

Your distribution function integrates to 1 on the whole line, but not on the half-line. It is not a valid distribution on [0,infinity].

Could you please edit the code sent?
Because I don’t understand what you mean

pdf.nb (24.9 KB)

There are probable mispellings: distGen for disGen, list for List. I suppose you mean

FindDistributionParameters[data[[i]], dist

instead of

FindDistributionParameters[data[[i]], ProbabilityDistribution

I already mentioned that you should write

init = {\[Mu] -> 3, \[Sigma] -> 2, \[Lambda]1 -> 0.5, \[Lambda]2 -> 
   0.5}

and not with \[RightArrow].

Your function f has integral less than 1 on the interval from 0 to infinity. It is not a valid PDF. This may turn into trouble when using FindDistributionParameters, as this simpler example shows:

myDist = ProbabilityDistribution[a x, {x, 0, 1}];
simulation = RandomVariate[myDist /. a -> 1, 1000];
Histogram[simulation]
FindDistributionParameters[simulation, myDist]

The program started spinning and then eventually writes that the program stopped working, so what is the reason?

14.nb (11.6 KB)

There is one more problem with your probability distribution f: it becomes negative for some values of the parameters, for example

{\[Mu] -> 3, \[Sigma] -> 2, \[Lambda]1 -> 1/2, \[Lambda]2 -> 1, 
 x -> 10}

My guess is that FindDistributionParameters cannot handle this.

Please is there any other way to solve this problem?

You can introduce assumptions into the probability distribution, to ensure that it is positive:

dist = ProbabilityDistribution[
  f[x, \[Mu], \[Sigma], \[Lambda]1, \[Lambda]2], {x, -\[Infinity], \
\[Infinity]}, 
  Assumptions -> 
   Reduce[
    ForAll[x, 0 < x < 1, 
     1 + \[Lambda]1  + 2 ( \[Lambda]2 - \[Lambda]1) x^2 - 
       3 \[Lambda]2  x^4 > 0], {\[Lambda]2, \[Lambda]1}, Reals]]

Then I don’t understand what you are trying to do with this:

MSE += (res - Values[init])^2 /. Rule \[RightArrow] list;

By the way, here too you should replace \[RightArrow] with ->

The problem is still there. Please, is there any other way to calculate this mean squared error?

This code works:

f[x, \[Mu], \[Sigma], \[Lambda]1, \[Lambda]2] = (1/\[Sigma]) E^-((
      x - \[Mu])/\[Sigma] + 
      E^-((x - \[Mu])/\[Sigma])) (1 + \[Lambda]1 + 
     2 ( \[Lambda]2 - \[Lambda]1) E^(- 
        E^-((x - \[Mu])/\[Sigma]))     - 
     3 \[Lambda]2  E^(- 2 E^-((x - \[Mu])/\[Sigma]))  );
dist = ProbabilityDistribution[
   f[x, \[Mu], \[Sigma], \[Lambda]1, \[Lambda]2], {x, -\[Infinity], \
\[Infinity]}, 
   Assumptions -> 
    Reduce[
     ForAll[x, 0 < x < 1, 
      1 + \[Lambda]1 + 2 (\[Lambda]2 - \[Lambda]1) x^2 - 
        3 \[Lambda]2 x^4 > 0], {\[Lambda]2, \[Lambda]1}, Reals]];
init = {\[Mu] -> 3, \[Sigma] -> 2, \[Lambda]1 -> 1/2, \[Lambda]2 -> 
    1/2} ;
distGen = dist /. init;
m = 50; n = 100;
FindDistributionParameters[data[[1]], dist, 
 ParameterEstimator -> "MaximumLikelihood"]

I don’t know what you want to do with the results.

Sorry, I forgot

data = RandomVariate[distGen, {m, n}];

Thank you very much.

How can calculate Log L, AIC, AICC, BIC, HQIC and CAIC