I have been trying to estimate the MLE for my joint posterior. I'm using R and the package stats4. I have 14 parameters and two of them are $\geq 0$, which I did not know how to implement (and I was creating NaN due to the minus log posterior required in for the mle function) and I just made it return very high value (1000) if either of the parameters were negative. Is this the right way to solve this problem? As I was forced to change my prior each time (because MLE told me that my prior estimates were way to high) and I find these nonnegative parameters going down to were low numbers (0.001 and 0.01) which did not seem right and at each iteration way below my suggested prior.

Also, since I didn't have the exact posterior due to the structure of the model and I tried to scale it such that the point estimate from the mle function plugged in the log joint posterior had the value 0. Is this approximation okay for this function?

  • 2
    $\begingroup$ Why are you doing MLE if you're dealing with a Bayesian problem? $\endgroup$
    – Glen_b
    May 12, 2014 at 2:50
  • $\begingroup$ I'm using block updating and in order to use that approach I need point estimate and covariance matrix to sample from and Metropolis-Hastings step to accept/reject. $\endgroup$
    – Raxel
    May 12, 2014 at 12:32
  • $\begingroup$ What does the stats4 package do? $\endgroup$
    – smillig
    May 12, 2014 at 13:31
  • 1
    $\begingroup$ @smilig it's part of the standard distribution of R. I believe stats4 is a library containing statistical functions based on S4 classes (as opposed to stats which contains a large collection of base stats functions using the older S3 classes). It (stats4) contains a number of highly generic workhorses like plot, summary, mle and so on. $\endgroup$
    – Glen_b
    May 12, 2014 at 21:28
  • $\begingroup$ Raxel: why not reparameterize the parameters with a lower bound (say by taking logs)? $\endgroup$
    – Glen_b
    May 13, 2014 at 5:37

1 Answer 1


Why use maximum likelihood for a Bayesian problem?

Nevertheless, the problem with two nonnegative parameters can be solved in several ways:

  • Using a solver which admits restrictions.

  • Maybe more practical, reparametrize the parameter, if it is $\theta_0 \ge 0$, represent it in the model as $\theta=\log \theta_0$. That admittedly also avoids the value zero, but it seems that's ok with you.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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