1

I'd like to know if there is a way to obtain statistical significance and p-value for correlation coefficients calculated for different raster in grass with the command r.covar

All that I obtain is the correlation matrix, but no information on statistical significance of these values.

1

The simplest would be to redirecting the output or the correlation matrix (using the flag -r) to a text file.

r.covar -r map=raster1@PERMANENT,raster2@PERMANENT > covar.txt

You have to run it from the Grass command line or from the Grass console in GUI to have the output in a text file. The output is an 2 x 2 symmetric covariance (correlation) matrix.

Please note that the text file will be saved in your present Grass directory. Check it in the Grass command line.

If you are using script in Python, it would be something like -

import grass.script as gscript
covar = gscript.parse_command('r.covar', flags='r', map=('raster1@PERMANENT','raster2@PERMANENT')
print covar
  • yes I can manage to obtain the correlation matrix. What I can't do is to obtain also the corresponding p-values – okapina Jul 17 '18 at 9:53
  • 1
    Sorry, I misinterpreted your question. There was an example from Grass 6.x at grass.osgeo.org/grass64/manuals/d.correlate.html using d.correlate, which uses r.stats and the UNIX awk command to calculate the correlation among data layers, and uses d.text and d.graph to display the results. But still p value is not shown. Not sure why Grass does not have (or not in my knowledge) such simple output anywhere.Probably just making a stack in R using 'raster' package and do the correlation there is an easier option? – Hasnein Tareque Jul 18 '18 at 5:33
  • 1
    Yes, indeed I finally managed to solve the issue in R. I found very useful this tutorial to compare 2 different time series hakimabdi.com/blog/… , obtaining also the spatial distribution of correlation coefficients and p-values. – okapina Jul 19 '18 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.