% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Persistence.R
\name{Persistence}
\alias{Persistence}
\title{Compute persistence}
\usage{
Persistence(data, time_dim = "sdate", sdate_beg, sdate_end, fyr_beg,
  fyr_end = fyr_beg, dates, memb = 1, na.action = 10, ncores = NULL)
}
\arguments{
\item{data}{A numeric array corresponding to the observational data
including the time dimension along which the autoregression is computed. The data
should start at least 40 years before 'sdate_beg'.}

\item{time_dim}{A character string indicating the dimension along which to 
compute the autoregression. The default value is 'sdate'.}

\item{sdate_beg}{A 4-digit integer indicating the first start date of the persistence
forecast.}

\item{sdate_end}{A 4-digit integer indicating the last start date of the persistence
forecast.}

\item{fyr_beg}{An integer indicating the forecast year for which
the persistence forecast should be calculated, or the first forecast
year of the average forecast years for which persistence should be
calculated.}

\item{fyr_end}{An (optional) integer indicating the last forecast year
of the average forecast years for which persistence should be calculated
in the case of a multiyear average persistence. The default value is 'fyr_beg'.}

\item{dates}{A sequence of 4-digit integers indicating the dates available
in the observations.}

\item{memb}{An integer indicating the number of ensemble members to
generate for the persistence forecast. The default value is 1.}

\item{na.action}{A function or an integer. A function (e.g., na.omit, 
na.exclude, na.fail, na.pass) indicates what should happen when the data 
contain NAs. A numeric indicates the maximum number of NA position allowed to
compute regression. The default value is 10.}

\item{ncores}{An integer indicating the number of cores to use for parallel
computation. The default value is NULL.}
}
\value{
A list containing:
\item{$persistence}{
 A numeric array with dimensions 'memb', start dates, latitudes and longitudes
 containing the persistence forecast.   
}
\item{$persistence.mean}{
 A numeric array with same dimensions as 'persistence', except the 'memb' dimension
 which is of length 1, containing the ensemble mean persistence forecast.
}
\item{$persistence.predint}{
 A numeric array with same dimensions as 'persistence', except the 'memb' dimension
 which is of length 1, containing the prediction interval of the persistence forecast.
}
\item{$AR.slope}{
 A numeric array with same dimensions as 'persistence', except the 'memb' dimension
 which is of length 1, containing the slope coefficient of the autoregression.
}
\item{$AR.intercept}{
 A numeric array with same dimensions as 'persistence', except the 'memb' dimension
 which is of length 1, containing the intercept coefficient of the autoregression.
}
\item{$AR.lowCI}{
 A numeric array with same dimensions as 'persistence', except the 'memb' dimension
 which is of length 1, containing the lower value of the confidence interval of the
 autoregression.
}
\item{$AR.highCI}{
 A numeric array with same dimensions as 'persistence', except the 'memb' dimension
 which is of length 1, containing the upper value of the confidence interval of the
 autoregression.
}
}
\description{
Compute a persistence forecast based on a lagged autoregression of 
observational data along the time dimension, with a measure of forecast 
uncertainty (prediction interval) based on Coelho et al., 2004.\cr\cr
}
\examples{
#Building an example dataset with yearly start dates from 1920 to 2009
obs1 <- 1 : (1 * 1 * 90 * 6 * 7)
dim(obs1) <- c(dataset = 1, member = 1, sdate = 90, lat = 6, lon = 7)
dates <- seq(1920,2009,1)
lon <- seq(0, 30, 5)
lat <- seq(0, 25, 5)
obs <- list(data = obs1, dates = dates, lat = lat, lon = lon)
persist <- Persistence(obs, sdate_beg = 1961, sdate_end = 2005, fyr_beg = 1,
                      dates = dates, memb = 40)

}

