My probability density function is a complicated one for which numerical estimation is necessary. Here my pdf:
pdf[s_?NumericQ] :=
combn NIntegrate[
N[q^k (1 - q)^(n - k), 100] (
E^(4 n q s) (1 - q)^(-1 + 4 n \[Mu]) q^(-1 + 4 n \[Nu]))/
NIntegrate[
E^(4 n q s) (1 - q)^(-1 + 4 n \[Mu]) q^(-1 + 4 n \[Nu]), {q, 1/(
2 n + 1), 1 - 1/(2 n + 1)}, MaxRecursion -> 12] , {q, 1/(
2 n + 1), 1 - 1/(2 n + 1)}, MaxRecursion -> 15]
Given some (realistic) values for the other parameters:
n = 25000;
k = 24991;
\[Mu] = 10^-4;
\[Nu] = 10^-4;
q = k/n;
combn = Binomial[n, k];
I can find the maximum likelihood estimate (MLE) over a given range of values with
MLE = FindMaximum[pdf[s], {s, 0.1, 0.6}] # Be carefull those calculations are slow!
Then, I can find the 95% confidence interval by doing
t = Table[pdf[s], {s, 0.1, 0.6, 0.01}]
Table[s, {s, 0.1, 0.6, 0.01}][[Flatten[
Position[t, _?(# > MLE[[1]] - 1.92 &)]]]]
But this is really not optimal because I have to recalculate pdf[s]
for all s
. If I were to calculate MLE from my t
only, then my estimate wouldn't be as accurate as with FindMaximum
because FindMaximum
calculate pdf[s]
over smaller increments as it get closer to MLE (at least that is what I assume, let me know if this is wrong).
What better (faster) solution can I use to get a good estimate of MLE and not-to-bad estimates of the boundaries of the confidence interval?
FindMaximum
. I also don't know how to implement that in Mathematica $\endgroup${{0.005, -28.5331}, {0.0670833, -6.87258}, {0.129167, -3.72334}, \ {0.19125, -2.68104}, {0.253333, -2.37156}, {0.315417, -2.38988}, \ {0.3775, -2.57275}, {0.439583, -2.84284}, {0.501667, -3.15976}, \ {0.56375, -3.50092}, {0.625833, -3.85318}, {0.687917, -4.20862}, \ {0.75, -4.56239}}
$\endgroup$pdf0Table = Block[ {sLow = 0.005, sHigh = 0.75, sStepNum = 12, sStep}, sStep = (sHigh - sLow)/sStepNum; Table[{s, pdf[s]}, {s, sLow, sHigh, sStep}] ]
$\endgroup$