Learn R Programming

ic.infer (version 1.1-7)

or.relimp: Function to calculate relative importance for order-restricted linear models

Description

The function calculates relative importance by averaging over the variables R-squared contributions from all orderings of variables for linear models with inequality restrictions on the parameters. NOTE: only useful if each restriction refers to exactly one variable, or if it is adequate to reduce multi-variable restrictions by omitting the affected variables but leaving the restriction otherwise intact.

Usage

or.relimp(model, ui, ci = NULL, ...)
# S3 method for lm
or.relimp(model, ui, ci = NULL, index = 2:length(coef(model)), meq = 0, 
     tol = sqrt(.Machine$double.eps), ...)
     
# S3 method for default
or.relimp(model, ui, ci = NULL, index = 2:ncol(model), meq = 0, 
     tol = sqrt(.Machine$double.eps), ...)
     
all.R2(covmat, ui, ci = NULL, index = 2:ncol(covmat), meq = 0, 
     tol = sqrt(.Machine$double.eps), ...)
     ## user does not need to call this function

Value

all.R2 returns a vector (2^p elements) with all R-squared values (p is the number of regressors, vector is ordered from empty to full model in natural order (cf. ic.infer:::nchoosek for the order within one model size).

or.relimp returns a vector (p elements) with average R-squared contributions from all models with respective subset of restrictions ui %*% beta >= ci enforced.

Arguments

model

a linear model object of class lm with data included; for function or.relimp, all explanatory variables must be numeric (i.e. no factors), and higher-order terms (e.g. interactions) are not permitted.

OR

the covariance matrix of the response (first position) and all regressors

covmat

the covariance matrix of the response (first position) and all regressors

ui

cf. explanation in link{orlm}; cf. also details below

ci

cf. explanation in link{orlm}

index

cf. explanation in link{orlm}

meq

cf. explanation in link{orlm}

tol

cf. explanation in link{orlm}

...

Further options

Author

Ulrike Groemping, BHT Berlin

Details

Function or.relimp uses function all.R2 for calculating the R-squared values of all subsets that are subsequently handed to function Shapley.value (from package kappalab), which takes care of the averaging over ordering.

WARNING: In models with subsets of the regressors, the columns of the matrix ui referring to regressors outside the current subset are simply deleted for the sub model. This is only reasonable if either the individual constraints refer to individual parameters only (e.g. all parameters restricted to be non-negative) or if the constraints are still reasonable in the sub model with some variables deleted, e.g. perhaps (depending on the application) sum of all parameters less or equal to 1.

WARNING: If the number of regressors (p) is large, the functions quickly becomes unmanageable (a vector of size 2^p is returned or handled in the process.

See Also

See also orlm for order-restricted linear models and calc.relimp from R-package relaimpo for a much more comfortable and much faster routine for unrestricted linear models

Examples

Run this code
covswiss <- cov(swiss)
## all R2-values for restricted linear model with restrictions that
## Catholic and Infant.Mortality have non-negative coefficients
R2s <- all.R2(covswiss, ui=rbind(c(0,0,0,1,0),c(0,0,0,0,1)))
R2s

require(kappalab) ## directly using package kappalab
Shapley.value(set.func(R2s))  

### with convenience wrapper from this package
or.relimp(covswiss, ui=rbind(c(0,0,0,1,0),c(0,0,0,0,1)))

### also works on linear models
limo <- lm(swiss)
#or.relimp(limo, ui=rbind(c(0,0,0,1,0),c(0,0,0,0,1)))

## same model using index vector
or.relimp(limo, ui=rbind(c(1,0),c(0,1)), index=5:6)

Run the code above in your browser using DataLab