next up previous
Next: Permutation tests Up: Methods available Previous: Multivariate phd


Adding other methods to dr

You may skip this section unless you are interested in adding additional dimension reduction methods to dr. The dr function is designed to be flexible and to make adding additional methods to the package as easy as possible. Here are the steps you need to follow:
  1. Select a name for your method. For example suppose you select the name ``poly'' to mean that you will be estimating $M$ by fitting polynomials to the inverse plots each of the predictors versus the response. When you call dr with method="poly", an object of class poly will be created. If your response is a matrix, the object will be of type mpoly, which inherits from poly.

    Table: The dr.fit.M method for sir.
    \begin{table}
\hrule
\small\begin{verbatim}
...


  2. You will need to write a function called dr.fit.M.poly that estimates the $M$ matrix for your method. You can model this function after the function dr.fit.M.sir shown in Table 1. The important arguments that are passed to this function include z, which is an $n \times p$ rotated and centered data matrix with no missing values; y, which is the response vector or matrix, and w, which is the vector of weights, if any. If your method requires other parameters, for example setting a degree of a polynomial, simply add the argument degree=2 to the list of function arguments. This sets the default value of degree equal to 2. The ``...'' argument in the functions allow you to add the degree argument when you call the function dr. Your function must return a list, including the argument M, which is the matrix of interest. $M$ can be either a square matrix leading to an analysis of eigenvalues and eigenvectors, as in the example for sir, or it can be a rectangular matrix, leading to use of singular values and vectors. All entries in the list will become attributes of the resulting object. For example, if your list is list(z=z,degree=degree), when you create an object like
    > i1 <- dr(LBM~Ht+Wt+RCC+WCC,method="poly",degree=3)
    
    the value of i1$degree will be 3.
  3. If your method works differently when y is a matrix, write a method called dr.fit.M.mpoly to do the computations for this case. For sir, the only difference between univariate and multivariate responses is in the way the slices are obtained, and the method dr.slices works for either case. As a result, a separate multivariate fit method is not required for sir.

    Table: The dr.test.sir function.
    \begin{table}
\hrule
\small\begin{verbatim}
dr.test.sir<-function(object,...
...tat'',''df'',''p-value''))
z
}\end{verbatim}
\normalsize\hrule
\end{table}


  4. If your method has tests, other than the permutation tests available for all methods, you will need to write a function called dr.test.poly (or dr.test.mpoly if a separate method is required for multivariate responses). The equivalent method for sir is shown in Table 2. The test method is called by the summary.dr function.
The function dr.fit.y(object) returns the response variable for use in computing $M$. For example, the function dr.fit.y.phdy returns the left-hand side variable from the formula specified in the call to dr, while dr.fit.y.phdres returns the residuals from the regression of the response on the predictors. You may also want to write a summary.dr.poly method if the default summary is not adequate for your needs.
next up previous
Next: Permutation tests Up: Methods available Previous: Multivariate phd
Sandy Weisberg 2002-01-10