ACC.Rd 6.09 KB
Newer Older
aho's avatar
aho committed
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ACC.R
\name{ACC}
\alias{ACC}
\title{Compute the anomaly correlation coefficient between the forecast and corresponding observation}
\usage{
ACC(exp, obs, dat_dim = "dataset", space_dim = c("lat", "lon"),
  avg_dim = "sdate", memb_dim = "member", lat = NULL, lon = NULL,
  lonlatbox = NULL, conf = TRUE, conftype = "parametric",
  conf.lev = 0.95, pval = TRUE, ncores = NULL)
}
\arguments{
\item{exp}{A numeric array of experimental anomalies with named dimensions.
It must have at least 'dat_dim' and 'space_dim'.}

\item{obs}{A numeric array of observational anomalies with named dimensions.
It must have the same dimensions as 'exp' except the length of 'dat_dim' 
and 'memb_dim'.}

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

\item{space_dim}{A character string vector of 2 indicating the name of the
latitude and longitude dimensions (in order) along which ACC is computed. 
The default value is c('lat', 'lon').}

\item{avg_dim}{A character string indicating the name of the dimension to be
dimension. It must be one of 'time_dim'. The mean ACC is calculated along 
averaged. If no need to calculate mean ACC, set as NULL. The default value 
is 'sdate'.}

\item{memb_dim}{A character string indicating the name of the member 
dimension. If the data are not ensemble ones, set as NULL. The default 
value is 'member'.}

\item{lat}{A vector of the longitudes of the exp/obs grids. Only required when
the domain of interested is specified. The default value is NULL.}

\item{lon}{A vector of the latitudes of the exp/obs grids. Only required when
the domain of interested is specified. The default value is NULL.}

\item{lonlatbox}{A numeric vector of 4 indicating the corners of the domain of
interested: c(lonmin, lonmax, latmin, latmax). Only required when the domain
of interested is specified. The default value is NULL.}

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

\item{conftype}{A charater string of "parametric" or "bootstrap". 
"parametric" provides a confidence interval for the ACC computed by a 
Fisher transformation and a significance level for the ACC from a one-sided
student-T distribution. "bootstrap" provides a confidence interval for the
ACC and MACC computed from bootstrapping on the members with 100 drawings 
with replacement. To guarantee the statistical robustness of the result, 
make sure that your experiment and observation always have the same number
of members. "bootstrap" requires 'memb_dim' has value. The default value is
'parametric'.}

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

\item{pval}{A logical value indicating whether to compute the p-value or not.
The default value is TRUE.}

\item{ncores}{An integer indicating the number of cores to use for parallel 
computation. The default value is NULL.}
}
\value{
A list containing the numeric arrays:\cr 
\item{ACC}{
 The ACC with the dimensions c(nexp, nobs, the rest of the dimension except 
 space_dim). nexp is the number of experiment (i.e., dat_dim in exp), and 
 nobs is the number of observation (i.e., dat_dim in obs).
}
\item{conf.lower}{
 The lower confidence interval with the same dimensions as ACC. Only present
 if \code{conf = TRUE}.
}
\item{conf.upper}{
 The upper confidence interval with the same dimensions as ACC. Only present
 if \code{conf = TRUE}.
}
\item{p.val}{
 The p-value with the same dimensions as ACC. Only present if 
\code{pval = TRUE}.  
}
\item{MACC}{
 The mean anomaly correlation coefficient with dimensions
 c(nexp, nobs, the rest of the dimension except space_dim and avg_dim). Only 
 present if 'avg_dim' is not NULL.
}
}
\description{
Calculate the anomaly correlation coefficient for the ensemble mean of each 
model and the corresponding references over a spatial domain. It can return a
forecast time series if the data contain forest time dimension, and also the 
start date mean if the data contain start date dimension. 
The domain of interest can be specified by providing the list 
of longitudes/latitudes (lon/lat) of the data together with the corners 
of the domain: lonlatbox = c(lonmin, lonmax, latmin, latmax).
}
\examples{
# See ?Load for explanations on the first part of this example.
 \dontrun{
data_path <- system.file('sample_data', package = 's2dverification')
expA <- list(name = 'experiment', path = file.path(data_path, 
            'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly',
            '$VAR_NAME$_$START_DATE$.nc'))
obsX <- list(name = 'observation', path = file.path(data_path,
            '$OBS_NAME$/$STORE_FREQ$_mean/$VAR_NAME$',
            '$VAR_NAME$_$YEAR$$MONTH$.nc'))

# Now we are ready to use Load().
startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101')
sampleData <- Load('tos', list(expA), list(obsX), startDates, 
                  leadtimemin = 1, leadtimemax = 4, output = 'lonlat',
                  latmin = 27, latmax = 48, lonmin = -12, lonmax = 40)
 }
 \dontshow{
startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101')
sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'),
                                               c('observation'), startDates,
                                               leadtimemin = 1,
                                               leadtimemax = 4,
                                               output = 'lonlat',
                                               latmin = 27, latmax = 48,
                                               lonmin = -12, lonmax = 40)
 }
sampleData$mod <- Season(sampleData$mod, 4, 11, 12, 2)
sampleData$obs <- Season(sampleData$obs, 4, 11, 12, 2)
clim <- Clim(sampleData$mod, sampleData$obs)
ano_exp <- Ano(sampleData$mod, clim$clim_exp)
ano_obs <- Ano(sampleData$obs, clim$clim_obs)
acc <- ACC(Mean1Dim(ano_exp, 2), Mean1Dim(ano_obs, 2))
 \donttest{
PlotACC(acc$ACC, startDates)
 }
}
\references{
Joliffe and Stephenson (2012). Forecast Verification: A 
 Practitioner's Guide in Atmospheric Science. Wiley-Blackwell.
}