[R] writing an R code for a given model
Ben Bolker
bbolker at gmail.com
Fri Oct 1 23:46:40 CEST 2010
Shige Song <shigesong <at> gmail.com> writes:
>
> Hi Abderrahim,
>
> I find this book particularly helpful:
> http://www.meb.ki.se/~yudpaw/likelihood/likelihood-index.htm
>
> Shige
>
> On Fri, Oct 1, 2010 at 12:15 PM, abderrahim youssef
> <abderrahim1302 <at> googlemail.com> wrote:
> > Dear R help list,
> >
> > I am desperately looking for any reference explaining by examples how to
> > write R codes in order to fit the parameters of a given model using maximum
> > likelihood or any other criteria function. I know the general structure:
> > First write a code for the maximum likelihood function and afterwards write
> > a code to maximize it using optim and then invert the Hessian to get the
> > standard errors and p-values. What I want is to find a document which
> > gives in detail the R code to do so for some given examples such as
> > linear mixed effect models, survival analysis etc ... where the likelihood
> > has a closed form and when it doesn't have a closed form ... I will then
> > follow the same structure to fit my own model.
You could take a look at the examples for the mle function in the 'stats4'
package; maxLik in the "maxLik" package; or mle2 in the 'bbmle' package
('bbmle' also has a vignette).
For what it's worth, likelihood estimation for mixed effects
models is non-trivial -- it involves either numerical integration or
clever analytical reduction to find a good approximation
or (in the case of linear mixed effect models) avoid the numerical
integration altogether. Not where I would start. (Parametric)
survival analysis should be easier.
More information about the R-help
mailing list