Re: [R] information on maximum likelihood

From: Gabor Grothendieck <ggrothendieck_at_myway.com>
Date: Tue 08 Mar 2005 - 01:10:38 EST

Ryan Glover <2ryang <at> rogers.com> writes:

:
: Hello,
:
: I have a time series that contains 40 years of daily average temperature. I
: am attempting to create a time series model for the temperature based on a
: number of papers that do the same. I have an expression that describes the
: temperature behavior over time but it contains 7 unknown parameters. The
: authors of the aforementioned papers state that they calculate the
: parameters using MLE but they do not discuss the topic further. A few days
: ago I was unaware of what MLE was. Now I know what it is, as well as
: someone can know in 72 hours, but I do not know how to perform the work to
: determine my own parameter values. I have read a number of help pages for R
: that relate to MLE but I admit to still being in the dark. Many examples
: discuss Poisson distributions and normal distributions but I don't think
: these apply to me since I already have my own expression for the time series
: data. Could someone please instruct me how to process my data set and my
: function in R with MLE so that it outputs values for my unknown parameters?

I assume from your post that you have the probability density, f(x,p), of your data as a function of your 40 year data vector x and your vector of 7 unknown parameters p. Define

        negloglik <- function(p) -log(f(x,p))

and run:

        nlm(negloglik, p0)

where p0 is a vector of starting values for p. See ?nlm . ?optim is an alternate possibility. If you have difficulties in getting convergence try different starting values, try using -f(x,p) instead of -log(f(x,p)), check out ?optim or try reparameterizing. Also you might check if your model fits into some category that R already knows about using the search facilities explained in the posting guide at the bottom.

Also, you might want to do repeated optimizations using many different starting values in case the likelihood has multiple local maxima.



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Mar 08 01:26:51 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:41 EST