0
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ What is $I_{(-\infty, \infty)}$? $\endgroup$ – Patrick Stevens Apr 3 '16 at 20:46
  • $\begingroup$ Also, pictures of code is really quite unhelpful. If you want us to debug code, please post… well, code, rather than pictures. $\endgroup$ – Patrick Stevens Apr 3 '16 at 20:50
  • $\begingroup$ Should this be moved to Mathematica SE? $\endgroup$ – Chris Rackauckas Apr 3 '16 at 21:25
  • $\begingroup$ $I_{(-\infty,\infty)}(x)$ is the indicator function. $\endgroup$ – dsmalenb Apr 3 '16 at 22:42
  • $\begingroup$ 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/… $\endgroup$ – Patrick Stevens Apr 4 '16 at 7:00
0
$\begingroup$

Just do

Variance[SechDistribution[m, s]]
Mean[SechDistribution[m, s]]
$\endgroup$
  • $\begingroup$ This will only work for this distribution. There are several other distributions I am working with where the parameters are not the mean and the variance. $\endgroup$ – dsmalenb Apr 3 '16 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.