[R] correlation value and map
Jenny Barnes
jmb at mssl.ucl.ac.uk
Wed Jan 10 14:43:20 CET 2007
Dear R-help community,
I have 2 different arrays of precipitation data each of the same dimensions of
[longitude, latitude, time] dim=[30,32,43], called array1 and array2. I need to
correlate them. This is the code I used to get one overall correlation value for
the whole of the area of interest:
> result <- cor(array1,array2,use="complete.obs")
> result
This give me a single value but I'm not convinced it is actually a correlation
value for the total area for the total time period of 43 years....can anybody
tell me if I am indeed wrong in my coding and/or indeed my low knowledge of the
statistics of correlation.
Also, I wanted to produce a correlation map over the 43 years. Could you also
advise me if this is correct, I am more confident that this is than the above
code:
> result <- array(NA, c(30,32))
>
> for(i in 1:30){
> for(j in 1:32){
> array1.ts <- array1[i,j,]
> array2.ts <- array2[i,j,]
> result[i,j] <- cor(array1.ts,array2.ts,use= "complete.obs")
> }
> }
I appreciate your time very much. If I don't iron out this problem now the
ground-work for my entire PhD will not be stable at all,
Many thanks for reading my problem, happy 2007 :-)
Jenny Barnes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jennifer Barnes
PhD student - long range drought prediction
Climate Extremes
Department of Space and Climate Physics
University College London
Holmbury St Mary, Dorking
Surrey
RH5 6NT
01483 204149
Web: http://climate.mssl.ucl.ac.uk
More information about the R-help
mailing list