# fitIWPCA: Robust fit of linear subspace through multidimensional data In aroma.light: Light-Weight Methods for Normalization and Visualization of Microarray Data using Only Basic R Data Types

## Description

Robust fit of linear subspace through multidimensional data.

## Usage

 ```1 2 3``` ```## S3 method for class 'matrix' fitIWPCA(X, constraint=c("diagonal", "baseline", "max"), baselineChannel=NULL, ..., aShift=rep(0, times = ncol(X)), Xmin=NULL) ```

## Arguments

 `X` NxK `matrix` where N is the number of observations and K is the number of dimensions (channels). `constraint` A `character` string or a `numeric` value. If `character` it specifies which additional contraint to be used to specify the offset parameters along the fitted line; If `"diagonal"`, the offset vector will be a point on the line that is closest to the diagonal line (1,...,1). With this constraint, all bias parameters are identifiable. If `"baseline"` (requires argument `baselineChannel`), the estimates are such that of the bias and scale parameters of the baseline channel is 0 and 1, respectively. With this constraint, all bias parameters are identifiable. If `"max"`, the offset vector will the point on the line that is as "great" as possible, but still such that each of its components is less than the corresponding minimal signal. This will guarantee that no negative signals are created in the backward transformation. If `numeric` value, the offset vector will the point on the line such that after applying the backward transformation there are `constraint*N`. Note that `constraint==0` corresponds approximately to `constraint=="max"`. With the latter two constraints, the bias parameters are only identifiable modulo the fitted line. `baselineChannel` Index of channel toward which all other channels are conform. This argument is required if `constraint=="baseline"`. This argument is optional if `constraint=="diagonal"` and then the scale factor of the baseline channel will be one. The estimate of the bias parameters is not affected in this case. Defaults to one, if missing. `...` Additional arguments accepted by `iwpca`(). For instance, a N `vector` of weights for each observation may be given, otherwise they get the same weight. `aShift, Xmin` For internal use only.

## Details

This method uses re-weighted principal component analysis (IWPCA) to fit a the nodel y_n = a + bx_n + eps_n where y_n, a, b, and eps_n are vector of the K and x_n is a scalar.

The algorithm is: For iteration i: 1) Fit a line L through the data close using weighted PCA with weights \{w_n\}. Let r_n = \{r_{n,1},...,r_{n,K}\} be the K principal components. 2) Update the weights as w_n <- 1 / ∑_{2}^{K} (r_{n,k} + ε_r) where we have used the residuals of all but the first principal component. 3) Find the point a on L that is closest to the line D=(1,1,...,1). Similarily, denote the point on D that is closest to L by t=a*(1,1,...,1).

## Value

Returns a `list` that contains estimated parameters and algorithm details;

 `a` A `double` `vector` (a[1],...,a[K])with offset parameter estimates. It is made identifiable according to argument `constraint`. `b` A `double` `vector` (b[1],...,b[K])with scale parameter estimates. It is made identifiable by constraining `b[baselineChannel] == 1`. These estimates are idependent of argument `constraint`. `adiag` If identifiability constraint `"diagonal"`, a `double` `vector` (adiag[1],...,adiag[K]), where adiag[1] = adiag[2] = ... adiag[K], specifying the point on the diagonal line that is closest to the fitted line, otherwise the zero vector. `eigen` A KxK `matrix` with columns of eigenvectors. `converged` `TRUE` if the algorithm converged, otherwise `FALSE`. `nbrOfIterations` The number of iterations for the algorithm to converge, or zero if it did not converge. `t0` Internal parameter estimates, which contains no more information than the above listed elements. `t` Always `NULL`.

## Author(s)

Henrik Bengtsson

This is an internal method used by the `calibrateMultiscan`() and `normalizeAffine`() methods. Internally the function `iwpca`() is used to fit a line through the data cloud and the function `distanceBetweenLines`() to find the closest point to the diagonal (1,1,...,1).