On Thu, 20 Nov 2008, Sam Veloz wrote:

I would like to run an anova on a set of raster variables imported from GRASS into R but am confused about how R handles the raster data. So if I have a model with a treatment with 2 levels, each raster is a binary file with cells coded for each level of the treatment. I have 1 response raster layer that corresponds spatially with the treatment layers. So let's say I have 5 rasters representing a different rep of the treatment how would I code this in R? I started out trying this:

treatment<-readRAST6(c("rep1","rep2","rep3","rep4","rep5"),cat=TRUE)
response<-readRAST6("response",cat=FALSE)
test.aov<-aov(response~treatment)

The objects returned by readRAST6 are SpatialGridDataFrames. I think that you may find that:

SGDF <- readRAST6(c("rep1", "rep2", "rep3", "rep4", "rep5", "response"),
  cat=c(TRUE, TRUE, TRUE, TRUE, TRUE, FALSE))
test.aov <- aov(response ~ ., data=SGDF)

does the trick (the . inserts the remaining variables) - or safer:

test.aov <- aov(response ~ rep1 + rep2 + rep3 + rep4 + rep5, data=SGDF)

Untried.

By the way, do you need aov(), or would anova(lm()) do the same? I guess the richer setting needs facilities in aov() that aren't visible here.

Hope this helps,

Roger


but I don't think this is right. Is it possible to do what I am trying? My data is actually a bit more complicated than this but if I can clear this up than I think I can do the rest on my own.
Thanks for your help,
Sam



--
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: [EMAIL PROTECTED]

_______________________________________________
grass-stats mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-stats

Reply via email to