Message Boards Message Boards

0
|
2960 Views
|
15 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Calculating bias and the mean squared error fails?

Posted 2 years ago

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}];
Attachments:
POSTED BY: Doaa Abd
15 Replies
Posted 2 years ago

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

POSTED BY: Doaa Abd

Sorry, I forgot

data = RandomVariate[distGen, {m, n}];
POSTED BY: Gianluca Gorni
Posted 2 years ago

Thank you very much.

POSTED BY: Doaa Abd

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.

POSTED BY: Gianluca Gorni
Posted 2 years ago

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

POSTED BY: Doaa Abd

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 ->

POSTED BY: Gianluca Gorni

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.

POSTED BY: Gianluca Gorni
Posted 2 years ago

Please is there any other way to solve this problem?

POSTED BY: Doaa Abd
Posted 2 years ago

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

Attachments:
POSTED BY: Doaa Abd

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]
POSTED BY: Gianluca Gorni

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].

POSTED BY: Gianluca Gorni

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].

POSTED BY: Gianluca Gorni
Posted 2 years ago

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

Attachments:
POSTED BY: Doaa Abd

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

POSTED BY: Gianluca Gorni
Posted 2 years ago

Thanks, but the problem is still there.

POSTED BY: Doaa Abd
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract