%\VignetteIndexEntry{Use Guide of Package}
%\VignetteDepends{}
%\VignetteKeywords{}


\documentclass[a4paper,12pt]{article}
\usepackage{verbatim}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{latexsym}
\usepackage{mathrsfs}
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{makeidx}
\usepackage{fancyhdr}
\usepackage{ulem}
\usepackage{url}

\newcommand{\indep}{\rotatebox[origin=c]{90}{$\models$}}


\title{Short introduction to package {\sffamily MAVE} with example}

\begin{document}

\SweaveOpts{concordance=TRUE}
\author{Hang Weiqiang(E0010758@u.nus.edu)}
\maketitle

\section{Introduction}
Package {\sffamily MAVE} provides several methods, including MAVE and OPG methods proposed by \cite{Xia2002,Xia2007,Xia2008},  to find the central space (CS) and the central mean space (CMS). It also implements sliced inverse regression of a kernel version; see \cite{Li1991,Xia2002}. Formal definition of the central space and the central mean space can be found in \cite{Cook1998,Cook2002}. For comparison, a package {\sffamily dr} in CRAN also contains other sufficient dimension reduction methods\cite{dr}.
%Sliced inverse regression was proposed by \cite{Li1991}, and more discussion can be found in \cite{SAVE}.

The main part of package {\sffamily MAVE} is written in C++ based on {\sffamily RcppArmadillo} package. If there is any problem during installation, please update your Rcpp package and install RcppArmadillo package and try again.

\section{Usage}
The primary function in this package is {\sffamily MAVE()}. The input arguments include an $n \times p$ covariate matrix $X$, an $n\times 1$ respond matrix $Y$, and the method argument for dimension reduction. The options for the method argument are {\sffamily 'csopg', 'csmave','meanopg','meanmave'} and {\sffamily 'ksir'}, and the default is {\sffamily 'csopg'}. {\sffamily 'csopg'} and {\sffamily 'csmave'} are methods of finding CS by OPG and MAVE respectively, {\sffamily 'meanopg'} and {\sffamily 'meanmave'} are methods of finding CMS by OPG and MAVE, {\sffamily 'ksir'} is the sliced inverse regression of kernel version. {\sffamily MAVE()} is very easy to use. The following is a simple example.

<<>>=
set.seed(12345)
library(MAVE)
x <- matrix(rnorm(400*5),400,5)
b1 <- matrix(c(1,1,0,0,0),5,1)
b2 <- matrix(c(0,0,1,1,0),5,1)
eps <- matrix(rnorm(400),400,1)
y <- x%*%b1 + (x%*%b2)*eps
dr <- mave(y~x, method='csmave')
@
In the example above, {\sffamily 'csopg'} is actually used. In many cases, the result of OPG is as good as MAVE but its computation is much more time-efficient, hence OPG method is recommended.

The class of object created by {\sffamily MAVE} function is a S3 class variable containing the matrix of CS or CMS  of different dimensions. By typing the name of the returned object, the output can be viewed.
<<>>=
dr
@
The output will display the first three matrices of CSs or CMSs estimated  by {\sffamily MAVE} function. To select dimension of the space by cross-validation method, {\sffamily DIM} method can be used.
<<>>=
dr.dim <- mave.dim(dr)
dr.dim
@
The output shows the corresponding cv-value for different dimensions. More information is stored in the object. These includes:
<<>>=
names(dr.dim)
@
In order to access other information such as CS or CMS all dimensions, just type
<<>>=
dr.dim$dir
@
In order to access the best CS or CMS selected by {\sffamily DIM} method, just type
<<>>=
mave.dir(dr.dim)
@


\begin{thebibliography}{9}
\bibitem{Li1991}
Li, K. C. (1991). Sliced inverse regression for dimension reduction. \textit{Journal of the American Statistical Association}, 86(414), 316-327.
\bibitem{Cook1998}
Cook, R.D.(1998),\textit{Regression Graphics}. New York: Wiley
\bibitem{Cook2002}
Cook, R. D., and Li, B. (2002). Dimension reduction for conditional mean in regression. \textit{Annals of Statistics}, 455-474.
\bibitem{Xia2002}
  Xia, Y., Tong, H., Li, W. K., and Zhu, L. X. (2002). An adaptive estimation of dimension reduction space. \textit{Journal of the Royal Statistical Society: Series B (Statistical Methodology)}, 64(3), 363-410.
\bibitem{Xia2007}
Xia, Y. (2007) A constructive approach to the estimation of dimension reduction directions.  \textit{Annals of Statistics}, 35(3), 2654-2690
\bibitem{Xia2008}
 Wang, H., and Xia, Y. (2008). Sliced regression for dimension reduction. \textit{Journal of the American Statistical Association}, 103(482), 811-821.
%\bibitem{dr}
%\href{https://CRAN.R-project.org/package=dr}
\bibitem{dr}
Weisberg, S. (2002). Dimension reduction regression in R. Journal of Statistical Software, 7(1), 1-22.
\end{thebibliography}

%\section{Function document}


\end{document}
