# MLE for Parameter Estimation using Mathematica

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}]]
solc = Solve[score == 0, mu]
Hessian[logLc, mu] /. solc


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.

• What is $I_{(-\infty, \infty)}$? – Patrick Stevens Apr 3 '16 at 20:46
• Also, pictures of code is really quite unhelpful. If you want us to debug code, please post… well, code, rather than pictures. – Patrick Stevens Apr 3 '16 at 20:50
• Should this be moved to Mathematica SE? – Chris Rackauckas Apr 3 '16 at 21:25
• $I_{(-\infty,\infty)}(x)$ is the indicator function. – dsmalenb Apr 3 '16 at 22:42
• Subscripts are bad for indexing in Mathematica, for various reasons [1]. Is there any reason you are using Subscript[x, i] instead of x[i]? [1]: mathematica.stackexchange.com/questions/94294/… – Patrick Stevens Apr 4 '16 at 7:00

Variance[SechDistribution[m, s]]