% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Regression.R
\name{Regression}
\alias{Regression}
\title{Computes The Regression Of An Array On Another Along A Dimension}
\usage{
Regression(vary, varx, posREG = "member", na.action = na.omit, formula = y
  ~ x)
}
\arguments{
\item{vary}{Array of any number of named dimensions.}

\item{varx}{Array of any number of named dimensions. 
The same dimensions as vary are expected.}

\item{posREG}{The name of the dimension along which to compute the regression.}

\item{na.action}{a logical value indicating whether NA values should be stripped before the computation proceeds or a numeric value indicating the maximum number of NA values allowed to compute the regression.}

\item{formula}{an object of class "formula" (see function \code{link[stats]{lm}}).}
}
\value{
\item{$regression}{
   Array with same dimensions as varx and vary except along posREG 
   dimension which is replaced by a length 4 dimension, corresponding 
   to the lower limit of the 95\% confidence interval, the slope, 
   the upper limit of the 95\% confidence interval and the intercept.
 }
 \item{$filtered}{
   Same dimensions as vary filtered out from the regression onto varx 
   along the posREG dimension.
 }
}
\description{
Computes the regression of the input matrice vary on the input matrice varx 
along the posREG dimension by least square fitting. Provides the slope of 
the regression, the associated confidence interval, and the intercept.\cr
Provides also the vary data filtered out from the regression onto varx.\cr
The confidence interval relies on a student-T distribution.
}
\examples{
vary <- 1:(2*3*4*5*6)
dim(vary) <- c(lat = 2, lon = 3, member = 4, time = 6, sdate = 5)
varx <- vary
res <- Regression(vary, varx, posREG = 'time')
str(res)
varx[c(1,5,7,9:22)] <- NA
res <- Regression(vary, varx, posREG = 'time', na.action = 2)
length(which(is.na(res$filtered)))
res <- Regression(vary, varx, posREG = 'time', na.action = 0)
length(which(is.na(res$filtered)))
vary[1] <- NA
res <- Regression(vary, varx, posREG = 'time')
res <- Regression(vary, varx, posREG = 'time', na.action = 5)
exp <- 1 : 70
obs <- rnorm(70)
dim(exp) <- c(time = 70)
dim(obs) <- c(time = 70)
reg <- Regression(exp, obs, posREG = 'time')
reg <- Regression(exp, obs, posREG = 'time', na.action = 10)

}
\author{
History:\cr
0.1  -  2013-05  (V. Guemas, \email{virginie.guemas@ic3.cat})  -  Original code\cr
1.0  -  2013-09  (N. Manubens, \email{nicolau.manubens@ic3.cat})  -  Formatting to CRAN
2.0  -  2019-10  (N. Perez-Zanon, \email{nuria.perez@bsc.es})  -  Formatting to multiApply
}
\keyword{datagen}

