[R] Does AIC() applied to a nls() object use the correct number of estimated parameters?

Adaikalavan Ramasamy ramasamy at cancer.org.uk
Fri Jul 16 05:13:35 CEST 2004

```I do not know anything about nls(), so apologies if I get it completely
wrong. help("AIC") says that AIC is defined to be
-2*log-likelihood + k*npar; where k = 2 by default.

I think you calculated -2*log-likelihood + k*(npar + 1) instead. Does
this help ?

On Fri, 2004-07-16 at 03:50, Peter.Caley at csiro.au wrote:
> I'm wondering whether AIC scores extracted from nls() objects using
> AIC() are based on the correct number of estimated parameters.
>
> Using the example under nls() documentation:
>
> > data( DNase )
> > DNase1 <- DNase[ DNase\$Run == 1, ]
> > ## using a selfStart model
> > fm1DNase1 <- nls( density ~ SSlogis( log(conc), Asym, xmid, scal ),
> DNase1 )
>
> Using AIC() function:
>
> > AIC(fm1DNase1)
> [1] -78.41642
>
> Using number of estimable coefficients (including residual error):
>
> > -2*logLik(fm1DNase1) + 2*(length(coef(fm1DNase1))+1)
> [1] -76.41642
> attr(,"df")
> [1] 3
> attr(,"nall")
> [1] 16
> attr(,"nobs")
> [1] 16
> attr(,"class")
> [1] "logLik"
>
> Based on the difference in AIC of 2 between the two approaches, it
> appears that when applied to a nls() object, AIC() doesn't include the
> estimate of residual error in the number of estimated parameters ... or
> is my understanding of nls() fitting confused.
>
> Any help appreciated.
>
> cheers
>
> Peter
>
> *********************************************************************
> Dr Peter Caley
> CSIRO Entomology
> GPO Box 1700, Canberra,
> ACT 2601
> Email: peter.caley at csiro.au
> Ph: +61 (0)2 6246 4076   Fax: +61 (0)2 6246 4000
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

```