I have a problem trying to maximize a log likelihood function in R.
My function has 5 parameters out of which I would like to constrain 3 to be positive while leave the other 2 (which should be very small, close to 0, but either positive or negative) as unconstrained.
How can I do this in R? So far, I have simply ran the constrained maximization in R asking the first 3 parameters to be bigger than 0 and asking for the other 2 to be bigger than a very small negative number (e.g., -300). The code in R looks like this:
optcinstMO<-constrOptim(c(1,1,1,1,1),f=neg.loglik2dLO, data1=x, data2=z, data3=y, method="Nelder-MEad",ui=rbind(c(1,0,0,0,0),c(0,1,0,0,0),c(0,0,1,0,0),c(0,0,0,1,0),c(0,0,0,0,1))ci=c(0,0,0,-300,-300))
where neg.loglik2dLO is the negative log-likelihood function I'm minimizing. Is there any other way of doing this "mixed" maximization problem in R?
Also, can anyone tell me what kind of error (if any) am I introducing to my maximization by using my "home-made" approach?