Localized SIR (SIR) is an extension of celebrated SIR method. As its name suggests,
the *locality* concept is brought in that for each slice, only local data points
are considered in order to discover intrinsic structure of the data.

```
do.lsir(
X,
response,
ndim = 2,
h = max(2, round(nrow(X)/5)),
preprocess = c("center", "scale", "cscale", "decorrelate", "whiten"),
ycenter = FALSE,
numk = max(2, round(nrow(X)/10)),
tau = 1
)
```

## Arguments

- X
an \((n\times p)\) matrix or data frame whose rows are observations
and columns represent independent variables.

- response
a length-\(n\) vector of response variable.

- ndim
an integer-valued target dimension.

- h
the number of slices to divide the range of response vector.

- preprocess
an additional option for preprocessing the data.
Default is "center". See also `aux.preprocess`

for more details.

- ycenter
a logical; `TRUE`

to center the response variable, `FALSE`

otherwise.

- numk
size of determining neighborhood via \(k\)-nearest neighbor selection.

- tau
regularization parameter for adjusting rank-deficient scatter matrix.

## Value

a named list containing

- Y
an \((n\times ndim)\) matrix whose rows are embedded observations.

- trfinfo
a list containing information for out-of-sample prediction.

- projection
a \((p\times ndim)\) whose columns are basis for projection.

## References

Wu Q, Liang F, Mukherjee S (2010).
“Localized Sliced Inverse Regression.”
*Journal of Computational and Graphical Statistics*, **19**(4), 843--860.

## Examples

```
## generate swiss roll with auxiliary dimensions
## it follows reference example from LSIR paper.
set.seed(100)
n = 123
theta = runif(n)
h = runif(n)
t = (1+2*theta)*(3*pi/2)
X = array(0,c(n,10))
X[,1] = t*cos(t)
X[,2] = 21*h
X[,3] = t*sin(t)
X[,4:10] = matrix(runif(7*n), nrow=n)
## corresponding response vector
y = sin(5*pi*theta)+(runif(n)*sqrt(0.1))
## try different number of neighborhoods
out1 = do.lsir(X, y, numk=5)
out2 = do.lsir(X, y, numk=10)
out3 = do.lsir(X, y, numk=25)
## visualize
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,3))
plot(out1$Y, main="LSIR::nbd size=5")
plot(out2$Y, main="LSIR::nbd size=10")
plot(out3$Y, main="LSIR::nbd size=25")
par(opar)
```