# [R] AIC using nls function

Bert Gunter gunter.berton at gene.com
Fri Aug 27 18:06:41 CEST 2010

```John:

1. As always, and as requested (see posting guide), a small
reproducible example might help.

2. What is CLi in your model?

3. In general, AIC  may not be particularly meaningful as a measure of
fit quality penalized for model complexity in NON-linear models unless
the different models are "nested" in very specific ways, which are
model-centric. The reason is that while the log likelihood part of AIC
is clearly defined (at least up to the quality of the convergence),
the number of parameters is not. That is, a single parameter in the
model may count as more or less than one parameter, in some sense.
Indeed, this is what distinguishes nonlinear from linear models where,
for example, the definition of "nested" models is mathematically
unequivocal (their basis vectors define nested linear subspaces). This
is not true for nonlinear models, because the manifolds in question
are nonlinear.  A detailed understanding and explanation of exactly
what this means exceeds my understanding. Doug Bates's PhD thesis and
subsequent papers (+ others, no doubt) go into this.

Cheers,

Bert Gunter
Genentech Nonclinical Statistics

On Fri, Aug 27, 2010 at 7:45 AM, John Ludlam <ludlam.john at gmail.com> wrote:
> Using the nls function I fit the following model (and some others) to my data.
> mod1=nls(CLr ~ A-(A-CLi)*exp(-k*d), start = list(A=60,k=0.005))
> I would like to rank a set of models using AIC.
>
> I calculated AIC as
> AIC(mod1)
>
> However, it appears to use an incorrect number of parameters (3
> instead of 2).  Why is this?
>
> Additionally, if I calculate AIC using the residuals sum of squares instead
> of the log likelihood, the AIC values, and resulting delta AICs differ between
> the two approaches.  What am I missing?
>
>
> Help is appreciated,
>
> John
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> and provide commented, minimal, self-contained, reproducible code.
>

```