\name{Teleconnection Patterns}

\alias{CorrPatterns, RegPatterns}
\title{
Correlation or regression patterns from EOF or REOF analysis
}
\description{
Computes a linear regression between PCs and and anomalies. CorrPatterns 
projects the principal components over a variable selected by the user and returns the correlation between the two time series, while RegPatterns returns the regression coefficient.
}
\usage{
CorrPatterns()
}
\arguments{
  \item{ano}{
Array of anomalies with dimensions (number of timesteps, number of longitudes,
number of latitudes).
  }
  \item{lon}{
Vector of longitudes of \code{ano}.
  }
  \item{lat}{
Vector of latitudes of \code{ano}.
  }
  \item{PCs}{
Matrix with the principal components (PCs) to project with dimensions (number of time steps, PC number)
  }
  \item{nPCs}{
Number of PCs to be visualized. Default = 4.
  }
  \item{show}{
Whether to visualize or not the projected teleconnection patterns in a composite figure (default: \code{FALSE}.
  }
  \item{nrows}{
If 'show' is (\code{TRUE}), set the number of rows of the composite figure with the regime patterns.
  }
  \item{ncols}{
If 'show' is (\code{TRUE}), set the number of columns of the composite figure with the regime patterns.
  }
  \item{var}{
If 'show' is (\code{TRUE}), add to the title of the composite figure the \% of explained variance of each teleconnection pattern.
  }
}
\value{
  \item{proj}{
An array of projected patterns normalized with dimensions (number of pattern, number of latitudes, number of longitues).
  }
}
\examples{
## Visualize the Euro-Atlantic teleconnection indexes with the Varimax rotation:
  \dontrun{
library(s2dverification)

## Load mean monthly sea level pressure (psl):
data <- Load('psl', exp = NULL,
             obs = 'ncep-reanalysis',
             sdates = paste0(1981:2015, '1201'),
             storefreq = 'monthly',
             leadtimemin = 1, leadtimemax = 3,
             latmin = 20, latmax = 80,
             lonmin = 270, lonmax = 60, output = 'lonlat')

## Measure psl anomalies dor DJF:
data.DJF <- Mean1Dim(data$obs, 4)
clim <- Mean1Dim(data.DJF, 3)
anom <- Ano(data.DJF, clim)
anom <- drop(anom)

## Rotate the PCs:
telec <- EuroAtlanticTC(ano = anom, lon = data$lon, lat = data$lat, ntrunc = 30)

## Project them with the correlation method:
CorrPatterns(ano = anom, lon = data$lon, lat = data$lat, PCs = telec$indices, nPCs = 4, show = TRUE, var = telec$var)

  }
}
\author{
History:\cr
0.1  -  2018-5  (N. Cortesi, \email{nicola.cortesi at bsc.es}), L. Lledo and V.Torralba -  Original code.\cr
}
\seealso{EuroAtlanticTC, REOF, EOF}
\keyword{datagen}
