# How to test for correlation between two weather station's data

I have about 15 weather stations, separated by quite a bit of kilometers. The data in these stations are the same for all, so is the resolution (daily).

I want to try and find which of the stations are actually correlated enough to perform some kind of predictive modelling. So in short, I would select a weather station and extract its values, and use those values in conjunction with nearby weather stations' values (for which they have strong correlation) to forecast the values for the selected weather station.

But that's the big picture here. And predictive modelling with ANN is already covered.

But how does one test if two or more locations are spatially correlated with regards to one of their weather variables?

Thanks to anyone who replies.

EDIT

The data (actual readings from stations) is a time series ranging from 2000 - 2016, this exists per station. So think of it like 15 different time series (what's the plural for series?). Variables range from average temps, wind speed, predicpitation, humidity and so on and so forth. (Precipitation here being the variable I want to forecast.)

At this stage, I want to test spatial correlation. But this part is just exploratory analysis, I just want to know which locations are correlated enough to consider. I won't be using all the stations, since that would just drive the Artificial Neural Network (ANN) insane. Will build the ANN later, but for now stations first.

EDIT 2

I'm a programmer not a statistician. If you guys have software that can do this automatically plus some documentation for its use and/or the actual math for it, that would be infinitely better.

EDIT 3 The space in question is an island about 104,530 km^2 in area.

My goal is basically just this, forecast the precipitation values of one station using the values from its history and values from history taken at other nearby (at least correlated in some modicum of strength) stations.

Forecast not predict. As was suggested, I changed terminology here. Problem stays the same though. And by that I want to forecast week ahead values for the station in question (aka. 7 days).

• right, right. will do. – ace_01S May 8 '17 at 3:58
• Can you show a map of your stations? Also, it is likely that a time component would be useful, even in exploratory analysis: consider migrating systems/fronts, so downwind station may be correlated with a time-lag. (Do you have wind direction or just speed?) – GeoMatt22 May 8 '17 at 4:20
• I just have speed really. I've got coordinates for each station, but I'll have to go through the process of putting them into R or something to see where they actually are in real world earth. – ace_01S May 8 '17 at 4:29
• OK. The scale of your problem (one county? one country? one hemisphere? global?) would have some impact on what stations may be reasonably connected and possible lags (e.g. see here). Given your update, can you elaborate on your goal? (i.e. vs. using standard weather-forecast products) – GeoMatt22 May 8 '17 at 4:46
• The scale is an island. About 104,530 km^2 in area. And as far as I know, I know not of any kind of product that does such a thing. I was hoping that fullly certified geostatisticians have their own set of tools and methods which I can jerry-rig with my own. As for my goal its basically just that, predict the precipitation values of one station using the values from its history and values from history taken at other nearby (at least correlated in some modicum of strength) stations. But before that takes of, the location correlations must be met - laws of geostatistics be damned (not really) – ace_01S May 8 '17 at 5:30

Your problem description is not too specific, so for exploratory analysis I can only give some general suggestions. (This may also be relevant.)

First, you should definitely visualize the weather stations on a map. Climate patterns will definitely vary depending on the scale of your problem as well as the geographic location (e.g. latitude, proximity to mountains/water bodies). This is also true of spatiotemporal precipitation patterns (e.g. see here).

Second, I would advise you to then check out some movies of satellite/doppler for the relevant area to "prime the intuition" about possible teleconnections. Because of advection, correlations between stations are likely to display time lags and anisotropy (e.g. downwind vs. cross-wind, relative to average wind direction/front migration).

A third step you might consider for exploratory data analysis would be to compute a correlation matrix between stations. To allow for time lags, you might consider cross correlation between time series at different stations. So you could compute a matrix of maximum cross-correlations between pairs of stations, along with a matrix of lag times. To assess distance-dependence (possibly anisotropic), for each station you could visualize a map scatterplot of its correlation to the other stations (e.g. using color and/or size of points to indicate the degree of correlation).

Since you mention that at this stage of your study, you want to test spatial correlation in an exploratory perspective, why not simply build a matrix representative of the correlation structure of your $n$ stations. Furthermore, since $n=15$, what I propose is easy to do, say, with excel.

Say you choose a weather variable $\boldsymbol{v}$, which is as follows

$\boldsymbol{v} = (v_1,...,v_n)^{'}$

where $\boldsymbol{v}$ is a $n \times 1$ vector.

Define $\boldsymbol{W} = [w_{ij} (d_{ij})] \equiv [e^{-\gamma d_{ij}}]$ or $\equiv [d_{ij}^{-\gamma}]$ or something else, which is distance-based. Note that distances in your case are geographic a fortiori.

$\boldsymbol{W}$ is a spatial weight matrix, entrywise specified to relate the distance-based strength of interaction between any position $i$ and $j$ of your space. And then you could compute the correlation between $\boldsymbol{v}$ and itself spatially lagged. I mean, computing

$\rho(\boldsymbol{v},\boldsymbol{W}\boldsymbol{v}) = \frac{E(\boldsymbol{v},\boldsymbol{W}\boldsymbol{v}) - E(\boldsymbol{v})E(\boldsymbol{W}\boldsymbol{v})}{\sigma_{\boldsymbol{v}}\sigma_{\boldsymbol{W}\boldsymbol{v}}}$

with $E(\boldsymbol{v},\boldsymbol{W}\boldsymbol{v})$ simply standing for the average of $((\boldsymbol{W}\boldsymbol{v})_{1} \times \boldsymbol{v}_1,...,((\boldsymbol{W}\boldsymbol{v})_{n} \times \boldsymbol{v}_n)^{'}$, $E(\boldsymbol{v})E(\boldsymbol{W}\boldsymbol{v})$ trivially is the product of each vector average and $\sigma$ their respective standard deviation.

If $\rho(\boldsymbol{v},\boldsymbol{W}\boldsymbol{v})$ is positive, it would mean that similar values of $\boldsymbol{v}$ tend to be close one to another. If $\rho(\boldsymbol{v},\boldsymbol{W}\boldsymbol{v})$ is negative, it would mean that dissimilar values of $\boldsymbol{v}$ tend to be close one to another. If it is null, you may want to try another specification for $\boldsymbol{W}$. Recalling that $\boldsymbol{W}$ may be a function of a unique parameter, $\gamma$ above, you can maximize your correlation coefficient over it. Of course, you may also want to check for the p-value associated with each computed spatial correlation.

Below is an example of how it can be easily done with excel, for $n=5$,

• That is a lot of math. Is this formula in literature? I can't even begin to understand how I'm gonna have to code this. I forgot to mention, I'm a Software Engineer, not a statistician. – ace_01S May 8 '17 at 4:21
• Does this talk to you @Ace_01S ? – keepAlive May 8 '17 at 4:46
• For exploratory data analysis, I do not think pre-defining weights is necessarily the way to go. The raw correlation matrix may be better (personally for $n=15$ I would check a scatterplot of each row, plotted in geographic space w/color or size of points based on corr.). Also something like peak cross-correlation magnitude and time-lag may be appropriate. These could be done automatically, w/o needing to do a "spatial correlation-wgt model selection" step up front. – GeoMatt22 May 8 '17 at 4:50
• One thing about the pre-defined weights is you cannot assume the spatial correlations are isotropic here (i.e. downwind vs. cross-stream distance may differ). BTW I am more an applied mathematician who masquerades as a geologist :) I am no meteorologist, for sure! – GeoMatt22 May 8 '17 at 4:55
• BTW I had some general thoughts on a related question. But for this type of problem my first advice would be to definitely check out some movies of satellite/doppler for the relevant area to "prime the intuition" about possible teleconnections, and definitely not treat the data as a "black box". – GeoMatt22 May 8 '17 at 5:07