[GRASS-stats] using LOESS on spatial data

Roger Bivand Roger.Bivand at nhh.no
Sat Jan 19 09:08:58 EST 2008


On Fri, 18 Jan 2008, Jarek Jasiewicz wrote:

> Hi all!
>
> first of all - all works and results are as I expeted.
> I rather like to consult your opinion about method I used to implement LOESS 
> (Local Polynomial Regression Fitting) to analize spatial data in R
>
> I prepared testing population of random point and sampled spGridDataFrame 
> (with overlay from sp package), next tried to fit local polinominal to points 
> and predict it on grid
> I tried it on the spPointDataFrame:
> ls=loess(height~coords,data=points,span=0.3), and of course it faliled

Inserting coordinates(points) does work, but generates unhelpful internal 
variable names (see str(ls)) and look for xnames).

>
> Next step was with to repit it with ordinary data frame:
> data.frame(points)
> ls=loess(height~(x+y), span=0.3)
>
> and predicted it on oridnary data frame:
>
> grid=data.fame(sp_grid)
> names(grid)=c("f","x","y")
> result=predict(ls,grid)
> and I've substituted: (result is numeric vector)
> sp_grid$f=result
> all is OK, values are as can expected and spatially corected
>
> So I have three question:
> -first: Is there any information about using R fo fit LOESS to spatial data 
> (I didn't found nothing abot it)

There may be some general information somewhere - this local regression 
may end up like using s(x,y) in gam() from mgcv, that is a non-parametric 
localised smooth.

> -second is posible and how process this with spatialgrid and spatial points 
> datasets (I suppose it will  be faster)

You'd need to write wrappers and it wouldn't be faster. The mechanism is 
that model fitting functions construct names of formula (and other 
argument) variables and store them in the object. The predict method then 
simply looks for the same names in the newdata object - if newdata$x 
exists, it will be used as new data for x

> -3th: is the procedure proper?

Like most non- and semi-parametric methods, that depends on your 
definition of proper. In mgcv, gam() uses cross-validation to choose the 
smoothing parameters. You might do something similar to choose the span= 
argument. If you have traning and testing data sets, you can see how well 
loess predicts the test data given the training data.

Hope this helps,

Roger

>
> regards
> Jarek
>
> _______________________________________________
> grass-stats mailing list
> grass-stats at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-stats
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the grass-stats mailing list