MLE for Parameter Estimation using Mathematica

151 Views Asked by At

I am using Mathematica (MMA) 10.0.0.0 with MathStatica do determine parameters using MLE for several PDFs. I have tried the approach below for several PDFs but I keep getting messages that Mathematica & MathStatica cannot analytically solve for the parameters. Although this may indeed be the case, I can solve for some analytically. So I think I may have some issues with my MMA code.

As an example, let $X_1,...X_n$ be i.i.d random variables from the hyperbolic secant distribution with location and scale parameters $\mu$ and $\sigma$:

\begin{equation*} f(x|\mu,\sigma) = \frac{1}{2\sigma} sech\left(\frac{x-\mu}{\sigma}\right)I_{(-\infty,\infty)}(x) \end{equation*}

I was able to show (analytically) that $\tilde{\mu}$ and $\tilde{\sigma}$ are respectively:

\begin{equation*} \tilde{\mu} = \bar{X} \end{equation*}

\begin{equation*} \tilde{\sigma} = \sqrt{\bar{X_n^2}-\left(\bar{X_n}\right)^2} \end{equation*}

If I run the following MMA code with MathStatica addon I do not get this (for readability, \[Sigma] and \[Mu] are replaced by sigma and mu):

f = 1/(2 sigma) Sech[(Pi (x - mu))/(2 sigma)];
domain[f] = {x, -Infinity, Infinity} && {sigma > 0};
logLc = Log[Product[(f /. x -> Subscript[x,i]), {i, 1, n}]]
score = Grad[logLc, mu]
solc = Solve[score == 0, mu]
Hessian[logLc, mu] /. solc

I receive the following output:

MMA Output

I suspect I am missing something or I am having issues since I am dealing with multiple parameters. I did try removing the location parameter and trying that for this example but I am still getting the issue.

Recall that I am trying to figure out why this does not work in this instance because I am planning to use this code for a couple more distributions. Therefore I cannot just use the mean and variance commands in MMA.

1

There are 1 best solutions below

1
On

Just do

Variance[SechDistribution[m, s]]
Mean[SechDistribution[m, s]]