Hi:

Is equation written as a function? As in, say,

eq <- function(k)  1/LR - (exp(-k * T) * LM) * (1 - exp(-k))

I believe the log of the likelihood would be a simpler expression to
maximize...

On Fri, Oct 1, 2010 at 1:39 PM, <mlarkin@rsmas.miami.edu> wrote:

> I am trying to figure out how to run maximum likelihood in R.  Here is my
> situation:
>
> I have the following equation:
> equation<-(1/LR-(exp(-k*T)*LM)*(1-exp(-k)))
>

This is a numeric vector, given LR, T, LM and k. If this is supposed to be a

function of k, then you have to define it as such. See above.

>
> LR, T, and LM are vectors of data.  I want to R to change the value of k
> to maximize the value of equation.
>
> My attempts at optim and optimize have been unsuccessful.  Are these the
> recommended functions that I should use to maximize my equation?
>
> With optim I wanted the function to be maximized so I had to make the
> fnscale negative.  Here is what I put:
>
> L<-optim(k,equation,control=(fnscale=-1))
>
> My result:   Error: could not find function "fn"
>
> This is because equation is not a function, given the definition you
provided above.

>
> Here is what I put for optimize:
>
> L<-optimise(equation,k,maximum=TRUE)
>
> My result:   Error: 'xmin' not less than 'xmax'
>
> Any advise would be greatly appreciated.
>

HTH,
Dennis

Mike
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

