[R] correlation value and map

From: Jenny Barnes <jmb_at_mssl.ucl.ac.uk>
Date: Wed 10 Jan 2007 - 13:43:20 GMT


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

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu Jan 11 00:50:58 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 10 Jan 2007 - 16:30:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.