\name{ACC_bootstrap}
\alias{ACC_bootstrap}
\title{
  Computes Anomaly Correlation Coefficient (Spatial Correlation)
}
\description{
  Matrix var_exp & var_obs should have dimensions (nexp/nobs,  nsdates,  
  nltimes,  nlat,  nlon).
  ACC computes the Anomaly Correlation Coefficient for each jexp in 
  1:nexp and each jobs in 1:nobs which gives nexp x nobs ACC for each 
  startdate and each leadtime.
  A domain can be selected by providing the list of longitudes/latitudes
  (lon/lat) of the grid together with the corner of the domain:
  lonlatbox = c(lonmin,  lonmax,  latmin,  latmax)
  The confidence intervale and the p-values are estimated from
  a bootstrap or permutation method
}

\usage{
ACC_bootstrap(var_exp, var_obs, sampmet, lon = NULL, lat = NULL,
                          lonlatbox = NULL, nrspa=1000,
                          blocspa=1, confmet = "quantile", center = TRUE)
} 
\arguments{
  \item{var_exp}{
    Matrix of experimental data with dimensions: 
    c(nexp, nsdates, nltimes, nlat, nlon)
  }
  \item{var_obs}{
    Matrix of observational data with the same dimensions as var_exp except 
    along the first dimension:
    c(nobs, nsdates, nltimes, nlat, nlon)
  }
  \item{sampmet}{
    "bootstrap"/"permutation". If "bootstrap" set, observation
    and experiment fields are re-sampled together. The original
    correlation should be included with a 95% probability in the
    confidence interval. In this case, the p-value can not be use to
    estimate the significance. Instead of using the p-value, the
    ACC or MACC will be considered significant if the confident
    interval does not include 0.
    If "permutation" set, a simple spatial permutation of the
    experiment field is done. The confidence interval will be center
    over 0 and can not be used directly as a "real confidence interval".
    The p-value is used to estimate the significance of the result and
    is defined as the percent of the sampled distribition higher than the
    estimated correlation.
  }
  \item{lon}{
    Array of longitudes of the var_exp/var_obs grids, optional.
  }
  \item{lat}{
    Array of latitudes of the var_exp/var_obs grids, optional.
  }
  \item{lonlatbox}{
    Domain to select : c(lonmin, lonmax, latmin, latmax), optional.
  }
  \item{nrspa}{
    number of sample for the bootstrap  (default: 1000)
  }
  \item{blocspa}{
    Length of spatial blocks used for resampling the field (default: 1)
  }
   \item{confmet}{
     "mason"/"quantile". If "mason" set, the lower/upper limit of 95%
     interval are estimated with the method based
     on Mason and Mimmack (1991). In the default case ("quantile"),
     simply the 2.5\% and the 97.5\% of the bootstrap distribution
     are given.
  }
  \item{center}{
    TRUE/FALSE if TRUE (default) compute the center anomaly correlation
    coefficient (using pearson correlation).
    if FALSE, the mean map anomalies are not substracted from both
    oberved and and experiement fields.
  }
}
\value{
  \item{ACC}{
    Matrix with c(nexp,  nobs,  nsdates,  nleadtimes,  4) dimensions.
    The fourth dimension of length 4 corresponds to the lower limit of
    the 95\% confidence interval,  the computed ACC,  the upper limit of 
    the 95\% confidence interval and the p-value.
    (see the detail of sampmet and confmet arguments for more details)
  }
  \item{MACC}{
    Matrix with c(nexp,  nobs,  nsdates,  nleadtimes,  4) dimensions.
    The fourth dimension of length 4 corresponds to the lower limit of
    the 95\% confidence interval,  the computed Mean Anomaly Correlation
    Coefficient, the upper limit of  the 95\% confidence interval
    and the p-value.
    (see the detail of sampmet and confmet arguments for more details)
  }
}
\author{
  History:
  1.0 -  2014-05  (C. Prodhomme, \email{chloe.prodhomme@ic3.cat})  -  Original code
}
\keyword{datagen}
