\name{Trend}
\alias{Trend}
\title{
  Compute Trends
}
\description{
  Compute trends along the (posTR)th dimension of matrix var by least square 
  fitting, and the associated an error interval.
  Provide also the detrended data.
  The confidence interval relies on a student-T distribution.
}
\usage{
  Trend(var, posTR = 2, interval = 1)
}
\arguments{
  \item{var}{
    Matrix of any number of dimensions up to 10.
  }
  \item{posTR}{
    Position along which to compute trends.
  }
  \item{interval}{
    Number of months between 2 points along posTR dimension.
    Default = 1.
  }
}
\value{
  \item{$trend}{
    Same dimensions as var except along posTR dimension which is replaced by a 
    length 3 dimension, corresponding to the lower limit of the  95% confidence 
    interval, the computed trends and the upper limit of the 95% confidence 
    interval for each point of the matrix along all the other dimensions.
  }
  \item{$detrended}{
    Same dimensions as var with linearly detrended var along the posTR 
    dimension.
  }
}
\author{
  History:
  1.0  -  2011-05  (V. Guemas, \email{vguemas@ic3.cat})  -  Original code
}
\keyword{datagen}
