Learn R Programming

hier.part (version 1.0-6)

hier.part: Goodness of Fit Calculation and Hierarchical Partitioning

Description

Partitions variance in a multivariate dataset

Usage

hier.part(y, xcan,
          family = c("gaussian", "binomial", "Gamma", "inverse.gaussian",
                    "poisson", "quasi", "quasibinomial", "quasipoisson",
                    "beta", "ordinal"),
          link = c("logit", "probit", "cloglog", "cauchit", "loglog"),
          gof = c("Rsqu", "RMSPE", "logLik"),
          barplot = TRUE, ...)

Arguments

y

a vector containing the response variable

xcan

a data.frame containing the n predictors

family

a character string naming a family function used by stats::glm (See stats::family for details of family functions). Valid values are "gaussian", "binomial", "Gamma", "inverse.gaussian", "poisson", "quasi", "quasibinomial","quasipoisson". Alternatively a value of "beta" will use the betareg::betareg beta regression model, or "ordinal" will use the MASS::polr ordered logistic or probit regression. For these last two options, a value for the link argument is required.

link

character specification of the link function, only used if family = "beta" or "ordinal". For "beta", this argument equals the "link" argument in betareg::betareg. For "ordinal", it equals the "method" argument in MASS::polr, where "logit" = "logistic".

gof

Goodness-of-fit measure. Currently "RMSPE", Root-mean-square 'prediction' error, "logLik", Log-Likelihood or "Rsqu", R-squared. R-squared is only applicable if family = "Gaussian".

barplot

If TRUE, a barplot of I and J for each variable is plotted expressed as percentage of total explained variance.

...

additional arguments to passed to glm, betareg::betareg, or MASS::polr

Value

a list containing

gfs

a data frame or vector listing all combinations of predictors in the first column in ascending order, and the corresponding goodness of fit measure for the model using those predictors.

IJ

a data frame of I, the independent and J the joint contribution for each predictor.

I.perc

a data frame of I as a percentage of total explained variance

params

a list of parameters used in the analysis, comprising: full.model formula, family, link, and gof.

Details

This function calculates goodness-of-fit measures for the full hierarchy of models using all combinations of N predictor variables using the function all.regs. The function takes the list of goodness-of-fit measures and, using the partition function, applies the hierarchical partitioning algorithm of Chevan and Sutherland (1991) to return a table listing each predictor, its independent contribution (I) and its conjoint contribution with all other variables (J), which cannot be ascribed separately to any one predictor.

Earlier versions of the hier.part package (<1.0) produced a matrix and barplot of percentage distribution of effects as a percentage of the sum of all Is and Js, as shown in Hatt et al. (2004) and Walsh et al. (2004). The current version plots the percentage distribution of independent effects only. The sum of Is equals the goodness-of-fit measure for the full model less the goodness-of-fit value of the null model.

The distribution of joint effects shows the relative contribution of each variable to shared variability in the full model. Negative joint effects are possible for variables that act as 'suppressors' of other variables (Chevan and Sutherland 1991).

The partition routine will not run for more than 12 predictors, but data sets with more than this number of predictors are unlikely to identify 'important' predictors.

References

Chevan, A. and Sutherland, M. 1991 Hierarchical Partitioning. The American Statistician 45, 90--96.

Hatt, B. E., Fletcher, T. D., Walsh, C. J. and Taylor, S. L. 2004 The influence of urban density and drainage infrastructure on the concentrations and loads of pollutants in small streams. Environmental Management 34, 112--124.

Mac Nally, R. 2000 Regression and model building in conservation biology, biogeography and ecology: the distinction between and reconciliation of 'predictive' and 'explanatory' models. Biodiversity and Conservation 9, 655--671.

Walsh, C. J., Papas, P. J., Crowther, D., Sim, P. T., and Yoo, J. 2004 Stormwater drainage pipes as a threat to a stream-dwelling amphipod of conservation significance, Austrogammarus australis, in south-eastern Australia. Biodiversity and Conservation 13, 781--793.

See Also

all.regs, partition, rand.hp

Examples

Run this code
# NOT RUN {
    #linear regression of log(electrical conductivity) in
    #streams against seven predictor variables
    #describing catchment characteristics (from
    #Hatt et al. 2004)

    data(urbanwq)
    env <- urbanwq[,2:8]
    hier.part(urbanwq$lec, env, fam = "gaussian", gof = "Rsqu")

    #logistic regression of an amphipod species occurrence in
    #streams against four independent variables describing
    #catchment characteristics (from Walsh et al. 2004).

    data(amphipod)
    env1 <- amphipod[,2:5]
    hier.part(amphipod$australis, env1, fam = "binomial",
              gof = "logLik")
# }

Run the code above in your browser using DataLab