[R] MLEs using optim
Rolf Turner
rolf.turner at xtra.co.nz
Tue Feb 7 00:22:31 CET 2012
On 07/02/12 03:24, djbanana wrote:
> I am trying to use the optim command to get the MLEs for a number of
> parameters based on some data. Is it possible to write a program that
> maximizes the likelihood and stores the parameters (many times)?
Of course it's possible. This is R.
> I need to
> do this a lot of times, each time the data will be updated with more entries
> (rows). I need to see how the new data is affecting the previous parameter
> estimates of the model. What is the best way to do it?
(1) Preallocate a list to hold the results.
(2) Use a for loop.
(3) Remember to use *double* brackets (``[[ ]]'') when assigning
a value to the i-th entry of your pre-defined list.
(4) For efficiency it is probably best to use the estimates returned
at step i as the starting values for step i+1.
cheers,
Rolf Turner
More information about the R-help
mailing list