% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.r
\name{EA.cor.f}
\alias{EA.cor.f}
\title{Compute and plot the cross correlation with lags between two E variables}
\usage{
EA.cor.f(x, y, years, x.EAR, y.EAR, diff = F, ...)
}
\arguments{
\item{x}{independent variable. E.g. "SST"}

\item{y}{dependent variable E.g. "T.deep"}

\item{years}{a vector of years you want to consider (the largest contiguous block in these years will be chosen)}

\item{x.EAR}{the ecosystem approach region for the independent variables}

\item{y.EAR}{the ecosystem approach region for the dependent variables}

\item{diff}{logical whether or not the variables should be differenced (removes non-stationarity)}

\item{...}{other arguments to ccf function for plotting in base R (type ?ccf)}
}
\description{
Computes the cross correlation between two selected variables with different lags. Given that you specify
   the independent and dependent variables, you are interested in negative or zero lags as an test of your hypothesis.
   If you selected years where data are not available, they are pairwise deleted before correlation and because of the
   hypothesis involved in lagged correlation analysis, only contiguous points (in time) are used. The largest of these
   contiguous blocks is selected as the data input for the analysis.
}
\details{
The ccf/acf function works differently than cor in a loop because it normalises the series only once at the beginning
   while every call to "cor" will renormalise with the truncated (lagged series). They will be the same for lag=0 though. They
   can, however, differ considerably especially for series with outliers at the ends and which is perhaps what we most often
   see with environmental data series under climate change. Given the increased probability of having an outlier presently
   under rapid climate change, it also means that causality inferred from a correlation analysis, especially a lagged one, is
   more susceptible to being overturned with a data update.
}
\examples{
      EA.cor.f("J.GSNW.Q3","T.deep",1800:2019,x.EAR=-1,y.EAR=1)
}
\author{
Daniel Duplisea
}
