[R] extractAIC using surf.ls

Roger Bivand Roger.Bivand at nhh.no
Thu Aug 10 09:49:34 CEST 2006


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
> 
> ______________________________________________
> R-help <at> stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
>



More information about the R-help mailing list