I'm having trouble trying to optimize a two-parameter exponential distribution, by finding the maximum likelihood function and then using the function optim() in R
log.lik.exp <- function(x, parametros){
n<-length(x)
y <- -1 *(n*log(parametros[1])-parametros[1]*(sum(x)-n*parametros[2]))
}
lambda<-2
gamma<-1
mydata <- rand.exp(100, gamma, 1/lambda)
optim(par=c(1,1),fn=log.lik.exp,x=mydata)$par
I'm also trying to use the function persp() to build a 3d plot to get a better look at the maximum values but I keep getting errors.
Thank you in advance, G.