ldr : An R Software Package for Likelihood-Based Suﬃcient Dimension Reduction

In regression settings, a suﬃcient dimension reduction (SDR) method seeks the core information in a p -vector predictor that completely captures its relationship with a response. The reduced predictor may reside in a lower dimension d < p , improving ability to visualize data and predict future observations, and mitigating dimensionality issues when carrying out further analysis. We introduce ldr , a new R software package that implements three recently proposed likelihood-based methods for SDR: covariance reduction, likelihood acquired directions, and principal ﬁtted components. All three methods reduce the dimensionality of the data by projection into lower dimensional subspaces. The package also implements a variable screening method built upon principal ﬁtted components which makes use of ﬂexible basis functions to capture the dependencies between the predictors and the response. Examples are given to demonstrate likelihood-based SDR analyses using ldr , including estimation of the dimension of reduction subspaces and selection of basis functions. The ldr package provides a framework that we hope to grow into a comprehensive library of likelihood-based SDR methodologies.


Introduction
Consider a regression or classification problem of a univariate response Y on a p × 1 vector X of continuous predictors. We assume that Y is discrete or continuous. When p is large, it is always worthwhile to find a reduction R(X) of dimension less than p that captures all regression information of Y on X. Replacing X by a lower dimensional function R(X) is called dimension reduction. When R(X) retains all the relevant information about Y , it is referred to as a sufficient reduction. Advantages of reducing the dimension of X include visualization of data, mitigation of dimensionality issues in estimating the mean function E(Y |X), and better prediction of future observations.
Most sufficient reductions consist of linear combinations of the predictors, which can be represented conveniently in terms of the projection P S X of X onto a subspace S of dimension d in R p . The subspace S is called a sufficient dimension reduction subspace if Y is independent of X given P S X. Under some conditions, the intersection of all dimension-reduction subspaces is also a dimension-reduction subspace which is referred to as the central subspace (Cook 1998). The central subspace is the parameter of interest in the sufficient dimension reduction framework.
Dimension reduction has been ubiquitous in the applied sciences with the use of principal components as the method of choice to reduce the dimensionality of data. However, principal components do not yield a sufficient reduction as the components are obtained with no use of the response. Numerous sufficient dimension reduction methods have been proposed in the statistics literature since the seminal paper of Li (1991) on sliced inverse regression (SIR). Among these methods are the sliced average variance estimation (SAVE, Cook and Weisberg 1991), principal Hessian directions (PHD, Li 1992), directional regression (Li and Wang 2007), and the inverse regression estimation (IRE, Cook and Ni 2005). These methods do not make any assumptions on the distribution of the predictors. Some recently developed methods adopt a likelihood-based approach. These methods assume a conditional distribution of the predictor vector X given the response Y , and include covariance reduction (CORE, Cook and Forzani 2008a), likelihood acquired directions (LAD, Cook and Forzani 2009), principal fitted components (PFC, Cook 2007;Cook and Forzani 2008b), and the envelope model (Cook, Li, and Chiaromonte 2010). The R (R Core Team 2014) package ldr (Adragni and Raim 2014) described in this article implements CORE, LAD and PFC.
At least two packages for sufficient dimension reduction can be found in the literature. One is the R package dr (Weisberg 2002) which implements SIR, SAVE, PHD, and IRE. The other package is LDR, a MATLAB (The MathWorks, Inc. 2012) package by Cook, Forzani, and Tomassi (2012) which implements CORE, LAD, PFC and the envelope model. The package introduced in this paper is the R counterpart of the MATLAB LDR package.
For the likelihood-based methods, except in some PFC model setups, there is no closed-form solution to the maximum likelihood estimator of the central subspace, which is the parameter of interest in dimension reduction framework. The maximum likelihood estimation is carried out over the set of all d-dimensional subspaces in R p , referred to as a Grassmann manifold, and denoted by G (d,p) . Optimization on the Grassmann manifold adds a layer of difficulty to the estimation procedure. Fortunately, a recent R package called GrassmannOptim (Adragni, Cook, and Wu 2012) has been made available for such optimization, which allows the current implementation of ldr in R. The implementation of GrassmannOptim uses gradient-based algorithms and embeds a stochastic gradient method for global search.
The package is built to use the typical command line interface of R. It has a hierarchical structure, similar to the dr package. The top command is ldr, which handles the maximum likelihood estimation of all parameters including the central subspace. The call of the ldr function, as described in the manual, is ldr(X, y = NULL, fy = NULL, Sigmas = NULL, ns = NULL, numdir = NULL, nslices = NULL, model = c("core", "lad", "pfc"), numdir.test = FALSE, ...) There are also functions which are specifically dedicated to each of the three models. Their calls are the following: core(X, y, Sigmas = NULL, ns = NULL, numdir = 2, numdir.test = FALSE, ...) lad(X, y, numdir = NULL, nslices = NULL, numdir.test = FALSE, ...) pfc(X, y, fy = NULL, numdir = NULL, structure = c("iso", "aniso", "unstr", "unstr2"), eps_aniso = 1e-3, numdir.test = FALSE, ...) For PFC and LAD, the reduction data-matrix of the predictor is also provided, and can be readily plotted. Available procedures allow the choice of the dimension of the central subspace using information criteria such as AIC and BIC (Burnham and Anderson 2002) and the likelihood ratio test.
The remainder of this article is organized essentially in two main sections. The concept of sufficient dimension reduction and a brief description of the three aforementioned likelihoodbased methods are provided in Section 2. Section 3 provides an overview of the package, along with examples on the use of the R package ldr to estimate a sufficient reduction. The package is available from the Comprehensive R Archive Network (CRAN) at http://CRAN. R-project.org/package=ldr.

Likelihood-based sufficient dimension reduction
We describe the following three sufficient dimension reduction methods: covariance reduction (Cook and Forzani 2008a), likelihood acquired directions (Cook and Forzani 2009), and principal fitted components (Cook 2007;Cook and Forzani 2008b). These methods are likelihoodbased inverse regression methods. They use the randomness of the predictors and assume that the conditional distribution of X given Y = y, denoted by X y , follows a multivariate normal distribution with mean µ y = E(X y ) and variance ∆ y = VAR(X y ). In some regressions R(X) may be a nonlinear function of X, but most often we encounter multi-dimensional reductions consisting of several linear combinations R(X) = Γ X, where Γ is an unknown p × d matrix, d ≤ p, that must be estimated from the data. Linear reductions are often imposed to facilitate progress. If Γ X is a sufficient linear reduction then so is (ΓM ) X for any d × d full rank matrix M . Consequently, only span(Γ), the subspace spanned by the columns of Γ, can be identified. The subspace span(Γ) is called a dimension reduction subspace.
If span(Γ) is a dimension reduction subspace, then so is span(Γ, Γ 1 ) for any matrix p × d 1 matrix Γ 1 . If span(Γ 1 ) and span(Γ 2 ) are both dimension reduction subspaces, then under mild conditions so is their intersection span(Γ 1 ) ∩ span(Γ 2 ) (Cook 1996(Cook , 1998. Consequently, the inferential target in sufficient dimension reduction is often taken to be the central subspace S Y|X , defined as the intersection of all dimension reduction subspaces (Cook 1994(Cook , 1998. A minimal sufficient linear reduction is then of the form R(X) = Γ X, where the columns of Γ now form a basis for S Y|X .
Let d = dim(S Y|X ) and let η denote a p × d semi-orthogonal matrix whose columns form a basis for S Y|X , so Y |X ∼ Y |η X. In other words, Y |X has the same distribution as Y |η X so that η X is sufficient to characterize the relationship between Y and X. The three aforementioned likelihood-based methodologies are designed to estimate S Y|X = span(η) under different structures for the mean function µ y and the covariance function ∆ y . Essentially, covariance reduction (CORE) is concerned with the problem of characterizing the covariance matrices ∆ y , y = 1, . . . , h, of X observed in each of h normal populations and does not utilize the population means µ y . The likelihood acquired directions (LAD) method considers both a general conditional covariance ∆ y and a general mean µ y . The principal fitted components (PFC) method considers a model for the mean function µ y , and while ∆ y = ∆ is assumed for all y, several structures of ∆ are involved. Each of these three methods is summarized in the sections that follow.

Covariance reduction
Covariance reducing models were proposed by Cook and Forzani (2008a) for studying the sample covariance matrices of a random vector observed in different populations. The models allow the reduction of the sample covariance matrices to an informational core that is sufficient to characterize the variance heterogeneity among the populations. It does not address the population means.
Let ∆ y , y = 1, . . . , h be the sample covariance matrices of the random vector X observed in each of h normal populations, and let S y = (n y − 1) ∆ y . The goal is to find a semi-orthogonal matrix Γ ∈ R p×d , d ≤ p, with the property that for any two populations j and k, That is, given Γ S y Γ and n y , the conditional distribution of S y must not depend on y. Thus Γ S y Γ is sufficient to account for the heterogeneity among the population covariance matrices. The central subspace is S Y |X = span(Γ).
The methodology is built upon the assumption that the S y 's follow a Wishart distribution and its development allows the covariance matrix for the population y to be modeled as where Γ 0 is an orthogonal completion of Γ, and M 0 and M y are symmetric positive definite matrices. En route to obtain the central subspace S Y |X , let ∆ y = VAR(X y ) and ∆ = E(∆ Y ), and define P Γ(∆y) = Γ(Γ ∆ y Γ) −1 Γ ∆ y as the projection operator that projects onto S Y |X relative to ∆ y . The central subspace span(Γ) is redefined to be the smallest subspace satisfying ∆ y = ∆ + P Γ(∆y) (∆ y − ∆)P Γ(∆y) .
This equality means that the structure of the covariance ∆ y can be decomposed in terms of the average structure of ∆ and a structure that is not shared with the other covariances. The maximum likelihood estimator of S Y |X is the subspace that maximizes over G (d,p) the log-likelihood function where P S indicates the projection onto the subspace S in the usual inner product, c is a constant that does not depend on S, and ∆ = h y=1 ∆ y . The maximum likelihood estimators of M 0 and M y are M 0 = Γ 0 ∆ Γ 0 and M y = Γ ∆ y Γ, where Γ is an orthogonal basis of the maximum likelihood estimator of S Y |X and Γ 0 is an orthogonal completion of Γ.
The dimension d of the central subspace must be estimated. A likelihood ratio test and information criterion were proposed to help estimate d. The likelihood ratio test Λ(d 0 ) = 2(L p −L d 0 ) was used in a sequential manner for the hypothesis H 0 : d = d 0 against H a : d = p, to choose d, starting with d = 0. The first hypothesized value of d that is not rejected is the estimated dimension d. The term L p denotes the value of the maximized log-likelihood for the full model with d 0 = p and L d 0 is the maximum value of the log-likelihood function in Equation 1. Under the null hypothesis Λ(d 0 ) is distributed asymptotically as a chi-squared random variable with degrees of freedom (p − d)(h − 1)(p + 1) + (h − 3)d/2, for h ≥ 2 and d < p.
With information criterion, the dimension d is selected to minimize over d 0 the function is the number of parameters to be estimated, and h(n) is equal to log n for the Bayesian criterion and 2 for Akaike's.

Likelihood acquired directions
The likelihood acquired directions method estimates the central subspace using both the conditional mean µ y and conditional variance function ∆ y . It assumes that X y is normally distributed with mean µ y and variance ∆ y , where y ∈ S Y = {1, . . . , h}. Continuous response can be sliced into finite categories to meet this condition. It furthermore assumes that the data consist of n y independent observations of X y , y ∈ S Y , and the total sample size is n = h y=1 n y . Let µ = E(X) and Σ = VAR(X) denote the marginal mean and variance of X and let ∆ = E(∆ Y ) denote the average covariance matrix. The subspace span(Γ) is the central subspace if and only if span(Γ) is the minimum subspace with the conditions The first condition (i.) implies that S ∆Γ , the subspace spanned by ∆Γ, falls into the subspace spanned by the translated conditional means µ y − µ. The second condition is identical to that of CORE.
Let Σ denote the sample covariance matrix of X, and let ∆ y denote the sample covariance matrix for the data with Y = y. The maximum likelihood estimate of the d-dimensional central subspace S Y |X maximizes over G (d,p) the log-likelihood function where |A| 0 indicates the product of the non-zero eigenvalues of a positive semi-definite symmetric matrix A, P S indicates the projection onto the subspace S in the usual inner product, and c is a constant independent of S. The desired reduction is then Γ X, where the columns of Γ form an orthogonal basis for the maximum likelihood estimator of S Y |X .
There is a striking resemblance between Equation 1 of CORE and Equation 2 of LAD. The difference is essentially that CORE extracts the sufficient information using the conditional variance only, while LAD uses both the conditional mean and the conditional variance.
The estimation of d is carried out as for CORE, using either the sequential likelihood ratio test or information criteria AIC and BIC. The statistic Λ(d 0 ) is distributed asymptotically as a chisquared random variable with degrees of freedom ( is equal to log n for BIC and 2 for AIC.

Principal fitted components
Principal fitted components methodology was proposed by Cook (2007) and estimates the central subspace by modeling the inverse mean function E(X|Y = y) while assuming that the conditional variance function ∆ is independent of Y . The response may be discrete or continuous. A generic PFC model can be written as where µ = E(X), β is an unconstrained d × r matrix, ε ∼ N (0, I), and f y ∈ R r is a known vector-valued function of y with linearly independent elements, referred to as basis functions. The basis function is a user-selected function; it is supposed to adequately help capture the dependency between the predictors and the response.
Several basis functions have been suggested in conjunction with PFC models (Cook 2007;Adragni and Cook 2009;Adragni 2009), including polynomial, piecewise polynomial, and Fourier bases. To gain an insight into the choice of the appropriate basis function, inverse response plots (Cook 1998) of X j versus y, j = 1, . . . , p could be used. In some regressions there may be a natural choice for f y . For example, suppose for instance that Y is categorical, taking values {1, . . . , h}. We can then set the kth coordinate of f y to be where J(·) is the indicator function and n k is the number of observations falling into category k.
When graphical guidance is not available, Cook (2007) suggested constructing a piecewise constant basis. With a continuous Y , an option consists of "slicing" the observed values into h bins (categories) and then specifying the kth coordinate of f y as for the case of a categorical Y . This has the effect of approximating each conditional mean E(X j |Y = y) as a step function of Y with h steps.
With a continuous Y , piecewise polynomial bases, including piecewise linear, piecewise quadratic and piecewise cubic polynomial bases, are constructed by slicing the observed values of Y into bins C k , k = 1, . . . , h. Let τ 0 , τ 1 , . . . , τ h denote the end-points or knots of the slices. For example, (τ 0 , τ 1 ) are the end-points of C 1 ; (τ 1 , τ 2 ) are the end-points of C 2 , and so on. We give here the description of the piecewise linear discontinuous basis f y ∈ R 2h−1 by its coordinates The number of components of f y is to be small enough compared to n to avoid modeling random variation rather than the overall shape between the response and individual predictor.
A number of structures of ∆ have been investigated. When the predictors are conditionally independent, ∆ has a diagonal structure; the isotropic PFC corresponds to the case with identical diagonal elements, while the anisotropic (initially called 'diagonal ' in Adragni and Cook 2009) is for the case of non-identical diagonal elements. The unstructured PFC refers to the case with a general structure for ∆ which allows conditional dependencies between the predictors. Extended structures are more evolved and involve expressions of ∆ that depend on Γ. We discuss each of these PFC models in the next sections.

Isotropic principal fitted components
The isotropic PFC (Cook 2007) assumes that ∆ = σ 2 I p . The central subspace is obtained as where P F denotes the projection operator onto the subspace spanned by the columns of F. The term Σ fit can be seen as the sample covariance matrix of the fitted vectors P F X from the multivariate linear regression of X on f , including an intercept. The maximum likelihood estimator for span(Γ) is the subspace spanned by the first d eigenvectors of Σ fit corresponding to its largest eigenvalues.
Turning to the estimation of the dimension d of the central subspace S Y|X , the likelihood ratio test Λ(d 0 ), and information criteria AIC and BIC used previously for CORE and LAD are still used.
To get the expression of the maximized log-likelihood, letλ fit i , i = 1, . . . , d be the eigenvalues of Σ fit such thatλ fit 1 > . . . >λ fit d and letλ i , i = 1, . . . , p be the eigenvalues of Σ, the sample covariance of X. The estimate of , and h(n) is equal to log n for BIC and 2 for AIC.

Anisotropic principal fitted components
The anisotropic PFC supposes that ∆ = diag(σ 2 1 , . . . , σ 2 p ). The central subspace is obtained as S Y |X = ∆ −1 S Γ . There is no closed-form expression of the maximum likelihood estimator of ∆ and Γ. An alternating algorithm is used to carry the maximum likelihood estimation. The idea is to notice that, letting that we can estimate span(Γ) as ∆ 1/2 times the estimate Γ of ∆ −1/2 Γ from the isotropic model (4). Withμ =X, alternating between these two steps leads to the following algorithm: 1. Fit the isotropic PFC model to the original data, getting initial estimates Γ (1) andβ (1) .
2. For some small > 0, repeat for j = 1, 2, . . . until Tr{( At convergence, the estimators Γ and ∆ are obtained to form the estimator of S Y|X as ∆ −1 S Γ , where S Γ is the subspace spanned by the columns of Γ. There is no closed-form expression of the maximized log-likelihood L d under the anisotropic model, but it can be numerically evaluated. The estimation of the dimension d is carried out similarly as described for the isotropic case.

Unstructured principal fitted components
Unstructured PFC (Cook and Forzani 2008b) assumes that the covariance matrix ∆ has a general structure, positive definite, and independent of y. The central subspace is To present the maximum likelihood estimator of the central subspace, let Σ res = Σ − Σ fit , and letω 1 > . . . ≥ω p and V = ( v 1 , . . . , v p ) be the eigenvalues and the corresponding eigenvectors of Σ −1/2 res Σ fit Σ −1/2 res . Finally, let K be a p×p diagonal matrix, with the first d diagonal elements equal to zero and the last p − d diagonal elements equal toω d+1 , . . . ,ω p . Then the maximum likelihood estimator of ∆ is ∆ = Σ 1/2 res V (I + K) V Σ 1/2 res (Theorem 3.1, Cook and Forzani 2008b). The maximum likelihood estimator of S Y|X is then obtained as the span of ∆ −1 times the first d eigenvectors of Σ fit .
The estimation of the dimension d is carried out as specified in the previous methods. The maximized value of the log-likelihood is given by , and h(n) is equal to log n for BIC and 2 for AIC.

Extended principal fitted components
The heterogenous PFC (Cook 2007) arises from a structure of ∆ as a function of Γ. Let Γ 0 be the orthogonal complement of Γ such that (Γ, Γ 0 ) is a p × p orthogonal matrix, and let Ω ∈ R d×d and Ω 0 ∈ R (p−d)×(p−d) be two positive definite matrices. The model can be written as X y = µ + Γβf y + ΓΩ 1/2 ε + Γ 0 Ω 1/2 0 ε 0 , where (ε , ε 0 ) ∼ N (0, I). The conditional covariance ∆ can be expressed as Then the subsequent PFC model is referred to as an extended PFC (Cook 2007). The central subspace is obtained as S Y|X = span(Γ). The maximum likelihood estimator of S Y|X maximizes over G (d,p) the log-likelihood function This expression (5) assumes that both Ω and Ω 0 are unstructured. The estimation of d is carried out as in the previous cases, using either a sequential likelihood ratio test or the information criteria.

Overview and use of the package
The following three functions, core, lad, and pfc mainly carry all the computations of the maximum likelihood estimation of the reduction subspaces and all other parameters for CORE, LAD, and PFC models. These functions could be called using the function ldr with a model argument for the appropriate model to use. For any of the models, the predictor data-matrix must be provided as an n × p matrix X. For core, covariance matrices may be provided in lieu of the predictor data-matrix.
Covariance reduction, LAD, and extended PFC rely on an external R package called Grass-mannOptim (Adragni et al. 2012) for the optimization. Additional optional arguments may be provided for the optimization, especially arguments related to simulated annealing for global optimization. It should be pointed out that two identical calls of the optimization function in GrassmannOptim may produce different numerical results if no random seed is set. This is due to the fact that subspaces are estimated, and they are not uniquely determined by a matrix. In addition, the optimization has a random search process embedded.
The dimension of the reduction subspace numdir must be provided. The boolean argument numdir.test determines the type of output with respect to the test on the dimension of the central subspace. When numdir.test is FALSE, no estimation of the dimension of the central subspace is carried out. Instead, the reduction subspace is estimated at the provided numdir.
With numdir.test being TRUE, a summary of the fit provides the AIC and BIC, along with the LRT for all values of the dimension less than or equal to the provided numdir. A default value of numdir is used when it is not provided by the user.
In the following sections, we provide some examples on the use of the ldr package. These examples are related to core, lad and pfc. In all cases, the goal is to estimate the central subspace.

An example with CORE
We replicate the results in Cook and Forzani (2008a) by applying CORE methodology to the covariance matrices of the garter snakes. The matrices are genetic covariance for six traits of two female garter snake populations, one from a coastal site and the other from an inland site in northern California. The data set was initially studied by Phillips and Arnold (1999). It is of interest to compare the structures of the two covariances and determine whether they share similarities.

ldr: Likelihood-Based Sufficient Dimension Reduction in R
We fit the model as follows: R> set.seed(1810) R> library("ldr") R> data("snakes", package = "ldr") R> fit <-ldr(Sigmas = snakes[-3], ns = snakes [[3]], numdir = 4, + model = "core", numdir.test = TRUE, verbose = TRUE, sim_anneal = TRUE, + max_iter = 100, max_iter_sa = 100) R> summary(fit) The optimization was carried out using a simulated annealing procedure that is optional within GrassmannOptim, the Grassmann manifold optimization procedure. The simulated annealing helps to avoid convergence to local maxima in the pursuit of a global maximum. The summary output below was obtained using the command summary(fit). It provides the results for the estimation of d, the dimension of the central subspace. The sequential likelihood ratio test rejects the null hypotheses for d = 0, d = 1, and fails to reject d = 2, thus the LRT procedure estimates d to bed = 2. The smallest AIC value is attained for d = 3, but the value of the objective function is close for d = 2 and d = 3. The smallest value of BIC is at d = 1, although the value of the objective function at d = 1 and d = 2 are close. Following the result from the LRT procedure we have reached the same conclusion as Cook and Forzani (2008a) in selectingd = 2, so two linear combinations of the traits are needed to explain differences in variation. The maximum likelihood estimator of the central subspace is span( Γ), that is span ( ] R> Mhat1 <-t(Gammahat) %*% Sigmahat1 %*% Gammahat R> Mhat2 <-t(Gammahat) %*% Sigmahat2 %*% Gammahat The estimated directions vectors that span the estimated central subspace arê These estimates are numerically different from the reported estimates from Cook and Forzani (2008a) but are quite close. The third element ofγ 1 and the fourth ofγ 2 are the largest entries for the two directions of the reduction matrix. We reach the same conclusions as Cook and Forzani (2008a) that the third and fourth traits are largely responsible for the differences in the covariance matrices.

Examples with LAD
We present two examples using the LAD procedure. The first example has a categorical response while the second has a continuous response. We use the flea dataset (Lubischew 1962) where the response is categorical. The data set contains 74 observations on six variables regarding three species of flea-beetles: concinna, heptapotamica, and heikertingeri. The measurements on the six variables are of continuous type. The goal is to find the sufficient directions that best separate the three species. This is essentially a discriminant analysis. We fit the following: R> data("flea", package = "ldr") R> fit <-ldr(X = flea[, -1], y = flea[, 1], model = "lad", + numdir.test = TRUE) The summary result of the fit obtained using the method summary for the fit object gives the following output:  This result suggests that the dimension of the central subspace isd = 2. The two directions are obtained as the sufficient reduction of the data that suffices to separate the three species. The method plot for the fit object plots the two directions as on Figure 1 using the code

R> plot(fit)
The second example uses the BigMac data set (Enz 1991). The data set gives the average values in 1991 on several economic indicators for 45 world cities, and contains ten continuous variables (X). The response (Y ), which is also continuous, is the minimum labor to purchase one BigMac in US dollars. The interest is in the regression of Y on X and we seek a sufficient reduction of X such that Y |X ∼ Y |α X, with α ∈ R p×d where d < p. Once α is estimated as a basis of the central subspace, the d components of α X can be used in place of X. The following code lines are used to fit a LAD model. Since the LAD methodology requires a discrete response, we provided the arguments nslices to be used to discretize the continuous response. We used three slices (nslices = 3) so that each slice has nine observations. The summary of the fit gives the following output: With three slices, the reduction would have at most two directions. The likelihood ratio test and the information criteria agree ond = 2. The plot of the fitted object fit is obtained by R> plot(fit) which produces Figure 2 of the two components of the reduction of the predictors against the response. The plot shows a nonlinear trend between the response and the first component of the sufficient reduction, with perhaps an influential observation. These two components are sufficient to characterize the regression of the response on the nine predictors.

An example with PFC
The performance of principal fitted components in estimating the central subspace may depend on the choice of the basis function f y . It is suggested to start with a graphical exploration of the data to have an insight into the appropriate degrees of the polynomial. If quadratic relationships are suspected, it might be best to use a cubic basis f y = (y, y 2 , y 3 ) . Piecewise constant and piecewise linear bases among others could be considered. The choice of f y is set by the function bf(y, case = c("poly", "categ", "fourier", "pcont", "pdisc"), degree = 1, nslices = 1, scale = FALSE) The following bases are implemented: polynomial basis (poly), categorical response (categ), Fourier basis (fourier), piecewise polynomial continuous (pcont), and piecewise polynomial discontinuous (pdisc). The argument degree specifies the degree of the polynomial, and nslices gives the number of slices when using piecewise polynomial bases. The columns of the data-matrix can optionally be scaled to have unit variance by specifying scale = TRUE.
Once the basis function is determined, the structure of ∆ should be investigated. With conditionally independent predictors, an isotropic or an anisotropic PFC might be suggested, otherwise an unstructured model should be used, assuming that the sample size is larger than the number of predictors. For a given dimension d for numdir, the structure may be determined by a likelihood ratio test.
We reconsider the BigMac data set (Enz 1991) for an example. An initial exploration suggests using a cubic polynomial basis function. We fit three models with isotropic, anisotropic and unstructured ∆ with the following code.
R> fy <-bf(bigmac[, 1], case = "pdisc", degree = 0, nslices = 5) R> fit1 <-pfc(X = bigmac[, -1], y = bigmac[, 1], fy = fy, + structure = "iso") R> fit2 <-pfc(X = bigmac[, -1], y = bigmac[, 1], fy = fy, + structure = "aniso") R> fit3 <-pfc(X = bigmac[, -1], y = bigmac[, 1], fy = fy, + structure = "unstr") R> structure.test(fit1, fit3) This output of this test has the results of the likelihood ratio test, and also of AIC and BIC. These results provide strong evidence against the isotropic structure. Similarly, we found strong evidence against the anisotropic structure in a test against the unstructured ∆. Thus, a model with unstructured covariance matrix is suggested. With such covariance structure, we then proceed to estimate the dimension of the central subspace. Using the following code with numdir.test = TRUE,   The likelihood ratio test, AIC and BIC all point to the dimension of the central subspace to bed = 1. The summary output also provides the eigenvalues of the fitted covariance matrix in decreasing order corresponding to the successive estimated reduction directions. In addition, linear regressions of the response on the components of the reduction are fitted. The coefficients of determination R 2 are provided for each fit.

Likelihood
The final fit with numdir = 1 is obtained with R> fit <-pfc(X = bigmac[, -1], y = bigmac[, 1], fy = fy, + structure = "unstr", numdir = 1) The plot of fit on Figure 3 is obtained by plot(fit). It shows a clear nonlinear relationship between the reduction of the predictors and the response. This single component reduction retains all the regression information of the response that is contained in the nine predictors.
The call to ldr provides a number of outputs including the estimates of the parameters. The list of outputs is provided by printing the fit object

R> fit
which gives the following list of components that are described in the package manual.

Variable screening with PFC
When dealing with a very large number of predictors and a substantial number of them do not contain any regression information about the response, it is often worth screening out these irrelevant predictors. The package contains a function called screen.pfc for that task. The methodology is based on the principal fitted components model. We provide a brief description and show an example of its use on a data set.

Inverse regression screening
We consider the normal inverse regression model (3) where ∆ is assumed independent of Y . Let X be partitioned into the vector of active predictors X 1 and the vector of inactive predictors X 2 . Assuming that X 2 X 1 |Y , let us partition Γ according to the partition of X as (Γ 1 , Γ 2 ) . Then X 2 Y if and only if Γ 2 = 0.
Screening the predictors by testing whether Γ 2 = 0 can be done by considering individual rows of Γ. A predictor X j is relevant or active when the corresponding row γ j of Γ is nonzero. We can thus test whether γ j = 0, j = 1, . . . , p. Equivalently, letting φ j = β γ j , the screening procedure is based upon whether φ j = 0 for each predictor X j . The hypothesis can be tested for each of the p predictors at a specified significance level α. The predictor X j will be set as active or relevant when H 0 is reject, and inactive or irrelevant otherwise. The model could be written for individual predictors as The relevance of a predictor X j is assessed by determining whether the mean function E(X jy ) = µ j + φ j f y depends on the outcome y. Model (7) is a forward linear regression model where the "predictor" vector is f y and the "response" is X j . An F test statistic can be obtained for the hypotheses (6). The predictor X j is relevant if the model yields an F statistic larger than a user-specified cutoff value. The cutoff may correspond to a significance level α such as 0.1 or 0.05 for example. The methodology was initially described in Adragni and Cook (2008).

Illustration
We applied the screening method to a chemometrics data set. The data is from a study to predict the functional hydroxyl group OH activity of compounds from molecular descriptors. The response (act) is the activity level of the compound, and the predictors are the nearly 300 descriptors. The response and predictors are continuous variables and 719 observations were recorded. The data set was provided by Tomas Oberg. We screened the descriptors at a 5% significance level.
The choice of the basis function determines the type of screening. For example, a correlation screening is obtained with a one degree polynomial basis function. A correlation screening selects the predictors linearly related to the response. The following example gives the correlation screening. R> out <-screen.pfc(X, fy = bf(y, case = "poly", degree = 1), cutoff = 0.05) The output shows an F statistic and p value for the test of dependence between the predictors and the response, where the latter is captured through a basis function. The Index corresponds to the index of the predictors. The predictors are sorted in the decreasing order of their F value. The following output is obtained with head(out The application of the correlation screening captured a set of 203 descriptors related to the response. However using a piecewise linear discontinuous basis function with two slices, the screening yielded a set of 235 descriptors, including 41 descriptors not detected by the correlation screening. Table 1 is a short list of some of the 41 descriptors captured by the piecewise linear discontinuous basis that were not selected by the correlation screening at the 5% significance level. This example shows that, as expected, when a relevant predictor is not linearly related to the response, a correlation screening may fail to capture it. However, with the appropriate choice of the basis function, all relevant predictors would be detected. Graphical investigations showed non-linear relationships between the response and some predictors listed on Table 1. Figure 4 plots log(act) against compounds sc3 and tets2 as two examples of predictors which were not selected by the correlation screening. A clear nonlinear relationship between the predictors and the log-transformed response is displayed. We used the log-transformation of the response to help see the graphical evidence of nonlinear relationship between the response and the mentioned predictors. The solid line is a loess smooth curve.

Conclusions
We have presented ldr, an R package for dimension reduction in regression. The package implements three recent likelihood-based methods for sufficient dimension reduction and a variable screening methodology. It can be considered as the likelihood-based addition to the R package dr. The package presents an architecture that allows the implementation of other sufficient dimension reduction methods such as the envelope model of Cook et al. (2010), which will be added in the near future. We foresee continuing the development of the package into a comprehensive library of tools and methods for likelihood-based sufficient dimension reduction in R.