% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Corr.R
\name{Corr}
\alias{Corr}
\title{Compute the correlation coefficient between an array of forecast and their corresponding observation}
\usage{
Corr(exp, obs, memb_dim = "member", sdate_dim = "sdate", comp_dim = NULL,
  limits = NULL, siglev = 0.95, method = "pearson", conf = TRUE,
  pval = TRUE, ncores = 1)
}
\arguments{
\item{exp}{A named numeric array of experimental data, with at least two 
dimensions 'sdate_dim' and 'memb_dim'.}

\item{obs}{A named numeric array of observational data, same dimensions as
parameter 'exp' except along memb_dim.}

\item{memb_dim}{A character string indicating the name of member (nobs/nexp) 
dimension. The default value is 'member'.}

\item{sdate_dim}{A character string indicating the name of dimension along
which the correlations are computed. The default value is 'sdate'.}

\item{comp_dim}{A character string indicating the name of dimension along which
the data is taken into account only if it is complete. The default value
is NULL.}

\item{limits}{A vector of two integers indicating the range along comp_dim to 
be completed. The default is c(1, length(comp_dim dimension)).}

\item{siglev}{A numeric indicating the confidence level for the 
regression computation. The default value is 0.95.}

\item{method}{A character string indicating the type of correlation: 
'pearson', 'spearman', or 'kendall'. The default value is 'pearson'.}

\item{conf}{A logical value indicating whether to retrieve the confidence 
intervals or not. The default value is TRUE.}

\item{pval}{A logical value indicating whether to compute or not the p-value 
of the test Ho: Corr = 0. The default value is TRUE.}

\item{ncores}{An integer indicating the number of cores to use for parallel 
computation. The default value is 1.}
}
\value{
A list containing the numeric arrays with dimension:\cr 
(# of datasets along memb_dim in exp, # of datasets along memb_dim in obs, 
all other dimensions of exp & obs except sdate_dim).\cr 
\item{$corr}{
 The correlation coefficient. 
}
\item{$p_val}{
 The p-value. Only present if \code{pval = TRUE}.
}
\item{$conf.lower}{
 The lower confidence interval. Only present if \code{conf = TRUE}.
}
\item{$conf.upper}{
 The upper confidence interval. Only present if \code{conf = TRUE}.
}
}
\description{
Calculate the correlation coefficient (Pearson, Kendall or Spearman) for 
an array of forecast and an array of observation.  
The correlations are computed along sdate_dim, the dimension corresponding 
to the startdate dimension. If comp_dim is given, the correlations are 
computed only if data along the comp_dim dimension are complete between  
limits[1] and limits[2], i.e., there is no NA between limits[1] and 
limits[2]. This option can be activated if the user wishes to account only 
for the forecasts which the corresponding observations are available at all 
leadtimes. \cr 
The confidence interval is computed by the Fisher transformation.\cr 
The significance level relies on an one-sided student-T distribution.\cr
}
\examples{
# Load sample data as in Load() example: 
example(Load) 
clim <- Clim(sampleData$mod, sampleData$obs) 
ano_exp <- Ano(sampleData$mod, clim$clim_exp) 
ano_obs <- Ano(sampleData$obs, clim$clim_obs) 
runmean_months <- 12 
dim_to_smooth <- 4  
# Smooth along lead-times   
smooth_ano_exp <- Smoothing(ano_exp, runmean_months, dim_to_smooth) 
smooth_ano_obs <- Smoothing(ano_obs, runmean_months, dim_to_smooth) 
leadtimes_per_startdate <- 60 
corr <- Corr(smooth_ano_exp, 
            smooth_ano_obs,
            comp_dim = 'ftime', #Discard start dates which contain any NA ftime             
            limits = c(ceiling((runmean_months + 1) / 2),                         
            leadtimes_per_startdate - floor(runmean_months / 2))) 

}
\author{
History:\cr
0.1  -  2011-04  (V. Guemas, \email{vguemas@bsc.es})  -  Original code\cr
1.0  -  2013-09  (N. Manubens, \email{nicolau.manubens@bsc.es})  -  Formatting to R CRAN\cr
1.1  -  2014-10  (M. Menegoz, \email{martin.menegoz@bsc.es})  -  Adding siglev argument\cr
1.2  -  2015-03  (L.P. Caron, \email{louis-philippe.caron@bsc.es})  - Adding method argument\cr
1.3  -  2017-02  (A. Hunter, \email{alasdair.hunter@bsc.es})  -  Adapted to veriApply()
3.0  -  2020-01  (A. Ho, \email{an.ho@bsc.es})  -  Adapt to multiApply
}
\keyword{datagen}

