\name{Composite}
\alias{Composite}
\title{
  Computes Composites
}
\description{
  Composites a 3-d field var(x,y,time) according to the indices of
  mode/cluster occurrences in time and computes the pvalues (t-test). 
}
\usage{
  Composite(var, occurrences, lag = 0, tflag = FALSE, nameout = NULL)
}
\arguments{
  \item{var}{
    3-dimensional tensor (x, y, time) containing the variable to composite.
  }
  \item{occurrences}{
    1-dimensional array for the occurrence time series of mode(s)/cluster(s) 
    (*1) when one wants to composite all modes, e.g., all K=3 clusters then
    for example occurrences could look like: 1 1 2 3 2 3 1 3 3 2 3 2 2 3 2,
    (*2) otherwise for compositing only the 2nd mode or cluster of the above 
    example occurrences should look like 0 0 1 0 1 0 0 0 0 1 0 1 1 0 1.
  }
  \item{lag}{
    Lag time step (an integer), e.g., for lag=2 composite will use +2
    occurrences (i.e., shifted 2 time steps forward). Deafult is lag=0.
  }
  \item{tflag}{
    For using the effective sample size (TRUE) or the total sample size 
    (FALSE that is the default) for the number of degrees of freedom.
  }
  \item{nameout}{
    Name of the .sav output file (NULL is the default). 
  }
}
\value{
  \item{$Composite}{ 
    3-d tensor (x, y, k) containing the composites k=1,..,K for case (*1)
    or only k=1 for any specific cluster, i.e., case (*2).
  }
  \item{$Pvalue}{
    3-d tensor (x, y, k) containing the pvalue of the 
    composites obtained through a t-test that accounts for the serial
    dependence of the data with the same structure as Composite.
  }
}
\examples{

#.. (add two examples)

}
\author{
  History:
  0.1  #  2014-08  (N.S. Fuckar, \email{neven.fuckar@ic3.cat})  #  Original code
}
\keyword{datagen}
