% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/MSSS.R
\name{MSSS}
\alias{MSSS}
\title{Compute mean square error skill score}
\usage{
MSSS(
  exp,
  obs,
  ref = NULL,
  time_dim = "sdate",
  dat_dim = NULL,
  memb_dim = NULL,
  pval = TRUE,
  sign = FALSE,
  alpha = 0.05,
  N.eff = NA,
  sig_method = "one-sided Fisher",
  sig_method.type = NULL,
  ncores = NULL
)
}
\arguments{
\item{exp}{A named numeric array of experimental data which contains at least
time dimension (time_dim). It can also be a vector with the same length as
'obs', then the vector will automatically be 'time_dim'.}

\item{obs}{A named numeric array of observational data which contains at least
time dimension (time_dim). The dimensions should be the same as parameter
'exp' except the length of 'dat_dim' and 'memb_dim' dimension. It can also 
be a vector with the same length as 'exp', then the vector will 
automatically be 'time_dim'.}

\item{ref}{A named numerical array of the reference forecast data with at 
least time dimension, or 0 (typical climatological forecast) or 1 
(normalized climatological forecast). If it is an array, the dimensions must
be the same as 'exp' except 'memb_dim' and 'dat_dim'. If there is only one
reference dataset, it should not have dataset dimension. If there is 
corresponding reference for each experiment, the dataset dimension must 
have the same length as in 'exp'. If 'ref' is NULL, the typical 
climatological forecast is used as reference forecast (equivalent to 0.)
The default value is NULL.}

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

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

\item{memb_dim}{A character string indicating the name of the member dimension
to compute the ensemble mean; it should be set to NULL if the data are
already the ensemble mean. The default value is NULL.}

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

\item{sign}{A logical value indicating whether to compute or not the 
statistical significance of the test Ho: MSSS = 0. The default value is 
FALSE.}

\item{alpha}{A numeric of the significance level to be used in the 
statistical significance test. The default value is 0.05.}

\item{N.eff}{Effective sample size to be used in the statistical significance
test with the Random Walk. It can be NA (and it will be computed with the 
s2dv:::.Eno), FALSE (and it will use the length of "obs" along "time_dim", so the 
autocorrelation is not taken into account), a numeric (which is used for 
all cases), or an array with the same dimensions as "obs" except "time_dim"
(for a particular N.eff to be used for each case). The default value is NA.}

\item{sig_method}{A character string indicating the significance method. The
options are "one-sided Fisher" (default) and "Random Walk".}

\item{sig_method.type}{A character string indicating the test type of the
significance method. Check \code{RandomWalkTest()} parameter 
\code{test.type} for details if parameter "sig_method" is "Random Walk". The
default is NULL (since "one-sided Fisher" doesn't have different test 
types.)}

\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 with dimension:\cr 
 c(nexp, nobs, all other dimensions of exp except time_dim).\cr
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). If dat_dim is NULL, nexp and 
nobs are omitted.\cr
\item{$msss}{
 A numerical array of the mean square error skill score. 
}
\item{$p.val}{
 A numerical array of the p-value with the same dimensions as $msss.
 Only present if \code{pval = TRUE}.
}
\item{sign}{
 A logical array of the statistical significance of the MSSS with the same
 dimensions as $msss. Only present if \code{sign = TRUE}.
}
}
\description{
Compute the mean square error skill score (MSSS) between an array of forecast 
'exp' and an array of observation 'obs'. The two arrays should have the same
dimensions except along 'dat_dim' and 'memb_dim'. The MSSSs are computed along
'time_dim', the dimension which corresponds to the start date dimension.
MSSS computes the mean square error skill score of each exp in 1:nexp 
against each obs in 1:nobs which gives nexp * nobs MSSS for each grid point 
of the array.\cr
The p-value and significance test are optionally provided by an one-sided 
Fisher test or Random Walk test.\cr
}
\examples{
# Load sample data as in Load() example:
example(LoadSampleData)
clim <- Clim(sampleData$mod, sampleData$obs)
ano_exp <- Ano(sampleData$mod, clim$clim_exp)
ano_obs <- Ano(sampleData$obs, clim$clim_obs)
rmsss <- MSSS(ano_exp, ano_obs, dat_dim = 'dataset', memb_dim = 'member')

# Synthetic data:
exp <- array(rnorm(30), dim = c(dataset = 2, time = 3, memb = 5))
obs <- array(rnorm(15), dim = c(time = 3, dataset = 1))
res <- MSSS(exp, obs, time_dim = 'time', dat_dim = 'dataset', memb_dim = 'memb')

}
