correlate

Calculates the Pearson Product-Moment Correlation coefficient of two variables over specified grids (i.e., independent variables)

var1 var2 [ grids ... ] minfrac correlate

Arguments
labeltypedescription
var1 variable variable to be correlated with var2
var2 variable variable to be correlated with var1

Note that var1 and var2 should have similarly-defined grids. Regridding one variable to match the other may be necessary (see example below).

grids grid set grid(s) (i.e., independent variables) over which correlation coefficient is to be calculated
minfrac number Minimum fraction of data that must be present (i.e., fraction not indicated as missing) within the selected domain in order for the correlation to be calculated. If minfrac is not present, then a missing value is returned. If minfrac is not given, then the correlation is calculated regardless of the amount of data present in the domain. (optional)
Returns
coefficient variable or constant Pearson-Product Moment Correlation coefficient of var1 and var2 over grids.

coefficient is not dependent on grids, but is dependent on any other grids that var1 or var2 depended on (if any).


Description

correlate calculates the Pearson product moment correlation for the two latest items on the stack over the indicated grid. For the correlation to be computed, the gridding of the two items on the stack must match.

Example

SOURCES .NOAA .NCEP .CPC .GMSM .w
T (Jan 1969) (Dec 1998) RANGE
X (-8) (20) RANGE
Y (8) (20) RANGE
SOURCES .DEKLIM .VASClimO .PrcpClim .Resolution-0p5x0p5 .prcp
T (Jan 1969) (Dec 1998) RANGE
X (-8) (20) RANGE
Y (8) (20) RANGE
[T]correlate


In this example, GMSM monthly soil moisture values are correlated over the time grid with monthly precipitation values from the VASClim0 data set for a region of West Africa over the period January 1969 to December 1998. The gridding of the two data sets matches in both space (0.5 deg. lat/lon resolution) and time. The result is a single map of correlation coefficients over the defined region of West Africa.

Live Example Link

OR

SOURCES .NOAA .NCEP .CPC .CAMS_OPI .v0208 .anomaly .prcp
T (Jan 1980) (Dec 2003) RANGE
X (-150) (-80) RANGE
Y (-10) (10) RANGE
SOURCES .NOAA .NCEP .EMC .CMB .GLOBAL .Reyn_SmithOIv2 .monthly .sst
T (Jan 1980) (Dec 2003) RANGE
X (-150) (-80) RANGE
Y (-10) (10) RANGE
[X Y]regridAverage
[X Y]correlate


In this example, CAMS_OPI monthly precipitation data are correlated in space with Reynolds and Smith OI Version 2 monthly sea surface temperatures over the equatorial Pacific Ocean. The result is a monthly time series of values from January 1980 to December 2003. The [X Y]regridAverage command was used to spatially regrid the SST data set (at 1.0 deg. lat/lon resolution) to match the gridding of the precipitation data set (at 2.5 deg. lat/lon resolution) before taking the correlation.

Live Example Link



See also

Statistical Functions: datarank distrib1D integrateddistrib1D medianover normalizeddistrib1D percentileover rankcorrelate replacebypercentile rmsaover rmsover seasonalfreqGT seasonalfreqLT seasonalmeandailyvalueGT seasonalnonoverlapDSfreq seasonalnonoverlapWSfreq seastotAvgFill seastotZeroFill standardize width96