Skip to content

do the standard R analysis functions handle spatial "grid" data?

3 messages · Chris Howden, Kingsford Jones, Robert J. Hijmans

#
Hi everyone,

I'm doing a resource function analysis with radio collared dingos and GIS
info.

The ecologist I'm working with wants to send me the data in a 'grid
format'...straight out of ARCVIEW GIS.

I want to model the data using a GLM and maybe a LOGISTIC model as well.
And
I was planning on using the glm and logistic functions in R.


Now I'm pretty sure that these functions require the data to be in a 2-D
spreadsheet format. And for me to call the responses and predictors as
columns from a data.frame (or 2-D matrix)

However I'm being told they can handle the data in a 'grid' format. So I'm
pretty sure this would mean I would be calling the responses and
predictors
as 2-d matrices...and I don't think these functions can do that?


Can anyone enlighten me?

Am I right in thinking these function cannot handle data in a 3-D 'grid'
format and require data to be entered as a 2-d data.frame or matrix?


Are there other special functions out there that can handle this type of
data, and I should be using these instead?

Thanks for your help

Chris Howden
Founding Partner
Tricky Solutions
Tricky Solutions 4 Tricky Problems
Evidence Based Strategic Development, IP development, Data Analysis,
Modelling, and Training
(mobile) 0410 689 945
(fax / office) (+618) 8952 7878
chris at trickysolutions.com.au
#
Not sure which 'logistic function' you're asking about, but logistic
regression is a case of the generalized linear model and can be fit
with base::glm.  It's been awhile since I've done this sort of thing
but as I recall I exported stacked rasters of predictors as XYZ ASCII
files (possibly after multiplying floating points by powers of 10 and
rounding to work with integers), and then merged on unique xy values
to form a matrix with one location (e.g raster cell centroid) per row
and k+2 columns where k is the number of layers and +2 for the x and y
values. Note that any glm inferences (including predictive inference)
will assume independent errors conditional on the model matrix.  To
use the xy values for independence diagnostics etc you'll want a
projection that preserves distance.

The rgdal, maptools and sp packages provide functions and classes for
working w/ spatial data (see the spatial Task View on CRAN).  Also, it
sounds as though the adehabitat package will be useful for your
application, and possibly the grasp and ModelMap packages as well.

Kingsford Jones



On Mon, Jul 12, 2010 at 8:51 PM, Chris Howden
<chris at trickysolutions.com.au> wrote:
#
You can also do this with the 'raster' package. See  ?raster::predict
Robert


On Mon, Jul 12, 2010 at 11:40 PM, Kingsford Jones
<kingsfordjones at gmail.com> wrote: