best.r.sq: Use R^2 to find the variables that best explain a...

best.r.sqR Documentation

Use R^2 to find the variables that best explain a multivariate response.


Finds the subset of explanatory variables in a formula that best explain the variation in a multivariate response, as measured by a chosen definition of R^2. Modifications are included for high dimensional data, such as multivariate abundance data in ecology.


best.r.sq(formula, data = parent.frame(), subset, var.subset,
  n.xvars= min(3, length(xn)), R2="h", ...)



a mvformula, a multivariate formula.


optional, the data.frame (or list) from which the variables in formula should be taken.


an optional vector specifying a subset of observations to be used in the fitting process.


an optional vector specifying the subset of the responses to be used.


the number of independent variables with the highest average R^2 that should be found.


the type of R^2 (correlation coefficient) that should be shown, possible values are:
"h" = Hooper's R^2 = tr(SST^(-1)SSR))/p
"v" = vector R^2 = det(SSR)/det(SST)
"n" = none Note that for a univariate response, all of these are equivalent to the ordinary product-moment correlation coefficient.


further arguments that are passed on to lm.


best.r.sq finds the n.xvars influence variables obtained by a forward selection in a multivariate linear model given by formula.
Only the response variables given by var.subset are considered. However, if var.subset is NULL all response variables are considered.
Interactions are excluded from the search mechanism, however the indices that are returned correspond to the indices in the model. This function is intended as an exploratory tool which can be used for example in plotting, and is not intended as a tool for formal model selection. choose 'all possible subsets' the moment)


This function returns a list consisting of:


a vector of indices of independent variables with the greatest explanatory power, as previously.


a vector of total R^2 from sequential model fits including each of the model terms identified in xs.


a matrix containing the total R^2 for each term in the model at each addition step (steps in columns and model terms in rows).


Ulrike Naumann and David Warton <>.


spiddat <- mvabund(spider$abund)
X <- as.matrix(spider$x)

best.r.sq( spiddat~X )

mvabund documentation built on March 18, 2022, 7:25 p.m.