[R] extractAIC using surf.ls

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Aug 11 09:17:03 CEST 2006


Roger, thank you for looking into this.

However, the posting guide asked the poster to contact the maintainer. Had 
(s)he done so, I would have pointed out that spatial 7.28-2 (the current 
version for R-devel) has this corrected (in a slightly simpler way).

On Thu, 10 Aug 2006, Roger Bivand wrote:

> Yan Wong <h.y.wong <at> leeds.ac.uk> writes:
> 
> > 
> > Although the 'spatial' documentation doesn't mention that extractAIC  
> > works, it does seem to give an output.
> 
> Could I suggest moving this question to the R-sig-geo list?
> 
> Please note that surf.ls() converts x and y to the [-1, +1] range to ensure that
> higher powers of possibly very large absolute coordinate values do not cause
> trouble, so that the surf.ls() and lm() models may differ anyway. 
> 
> I believe that there is a bug in extractAIC.trls() - which I contributed to the
> spatial package some years ago, with edf <- df.residual.trls(fit) rather than n
> - df.residual.trls(fit). When this is corrected, for this case, the extractAIC()
> results agree.
> 
> Roger Bivand
> 
> > I may have misunderstood, but shouldn't the following give at least  
> > the same d.f.?
> > 
> >  > library(spatial)
> >  > data(topo, package="MASS")
> >  > extractAIC(surf.ls(2, topo))
> > [1]  46.0000 437.5059
> >  > extractAIC(lm(z ~ x+I(x^2)+y+I(y^2)+x:y, topo))
> > [1]   6.0000 357.5059
> > 
> > # and if the AIC values differ, shouldn't they do so by an additive  
> > constant?
> > 
> >  > (extractAIC(surf.ls(2, topo))-extractAIC(lm(z ~ x+I(x^2)+y+I(y^2) 
> > +x:y, topo)))[2]
> > [1] 80
> >  > (extractAIC(surf.ls(1, topo))-extractAIC(lm(z ~ x+y, topo)))[2]
> > [1] 92
> > 
> > # Using R 2.3.1 (OS X), spatial version 7.2-27.1
> > 
> > Thanks
> > 
> > Yan

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list