# Using MLE in R stats4

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?

• Why are you doing MLE if you're dealing with a Bayesian problem? May 12, 2014 at 2:50
• 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. May 12, 2014 at 12:32
• What does the stats4 package do? May 12, 2014 at 13:31
• @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. May 12, 2014 at 21:28
• Raxel: why not reparameterize the parameters with a lower bound (say by taking logs)? May 13, 2014 at 5:37

• 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.