On Thu, 4 Aug 2011, Rebecca Bennett wrote:

Great, this worked, thank you for your quick reply Roger. The missing values are intended - I didn't realise that I had to specify such to R.


This probably going to show my vast ignorance of R in comparison to SPSS, but is there a way to tell / set the significance level for the analysis?

?cor.test

but beware that your observations are not independent, and will have inflated significance levels, so the test output really should not be used unless you can first show that there is no spatial autocorrelation in either variable. You could look at ?Geary in the raster package as a way of checking autocorrelation. If you are an ecologist, you could look at Fortin & Dale for background, and maybe the Numerical ecology with R useR! book from Springer. The Moran() and Geary() functions in raster don't give you a significance test for autocorrelation, though, you may need other approaches in spdep for that.

Hope this helps,

Roger


cheers,
Rebecca




________________________________
From: Roger Bivand <[email protected]>
To: Rebecca Bennett <[email protected]>
Cc: "[email protected]" <[email protected]>
Sent: Thursday, 4 August 2011, 10:41
Subject: Re: [GRASS-stats] Correlation calculation

On Thu, 4 Aug 2011, Rebecca Bennett wrote:

Hello all,

I am *very* new to R and am experimenting with the GRASS / R interface to look at correlation of elevation and spectral values.

Reading through the literature and mailing list, I have imported my GRASS rasters to R as a dataset looked at the summary statistics and then attempted to run a correlation analysis using cor, along the lines of the example here:


map <- readRAST6(c("lageado_10k_fisher_K_15x15",    "lageado_10k_fisher_K_25x25")) summary(map)

I think that here you will see that for your current GRASS region, there are missing values (NAs) in the first attribute.

cor(as(map, "data.frame")) and get the output:


                coombe_rev_LRM intensity_coombe          x          y
coombe_rev_LRM                1               NA         NA         NA
intensity_coombe          NA       1.00000000 -0.1525509 0.09057913
x                                NA      -0.15255095  1.0000000 0.00000000
y                                NA       0.09057913  0.0000000 1.00000000



so results for intensity_coombe are given, but not for coombe_rev_LRM. The x and y are the coordinates of the raster cells are uninteresting, and are added when you use as(..., "data.frame"). Try:

cor(as(map, "data.frame")[,1:2], use="complete.obs")

to use only the two real attributes, and to drop observations where there are missing values. Do check that the missing values are intended, as they may be caused by your region setting in GRASS.

Hope this helps,

Roger


so the correlation is running on the x and y values of the rasters not the z?

How do I begin to assess correlation in the z value of two rasters?

Many thanks for reading, (and sorry if my question seems stupid or I have missed something obvious)

Rebecca

-- Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [email protected]




--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
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