hier.part: Goodness of Fit Calculation and Hierarchical Partitioning

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/hier.part.R

Description

Partitions variance in a multivariate dataset

Usage

1
2
3
4
5
6
7
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

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.

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.

Note

The function produces a minor rounding error for analyses with more than than 9 predictors. To check if this error affects the inference from an analysis, run the analysis several times with the predictors entered in a different order. There are no known problems for analyses with 9 or fewer predictors.

Author(s)

Chris Walsh cwalsh@unimelb.edu.au using c and fortran code written by Ralph Mac Nally Ralph.MacNally@gmail.com.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
    #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")

Example output

Loading required package: gtools
$gfs
  [1] 0.00000000 0.59047318 0.82682075 0.01098174 0.39635905 0.12282709
  [7] 0.62445471 0.33033972 0.83410378 0.59758915 0.62061433 0.65284362
 [13] 0.77159448 0.60702109 0.82683793 0.82691037 0.83582029 0.85403927
 [19] 0.84727070 0.41798147 0.13980912 0.76026824 0.33080645 0.39744819
 [25] 0.66503431 0.52650125 0.67608730 0.43330271 0.64633406 0.83447868
 [31] 0.83411192 0.83965414 0.85551898 0.84727151 0.62061622 0.65949970
 [37] 0.82672399 0.62672410 0.65445206 0.77226833 0.62512912 0.77811174
 [43] 0.66312305 0.82026934 0.82691040 0.84141253 0.87751308 0.84785650
 [49] 0.83932285 0.85513956 0.84985538 0.85490360 0.85107746 0.87685251
 [55] 0.43348171 0.81801707 0.55827372 0.76851361 0.50536622 0.77107209
 [61] 0.73969961 0.53654123 0.68316625 0.67713148 0.83451931 0.84541929
 [67] 0.87865868 0.84793008 0.84176310 0.85633390 0.85010056 0.85662169
 [73] 0.85116200 0.88236321 0.66297682 0.84039075 0.62908864 0.82701685
 [79] 0.66414800 0.85116957 0.78348135 0.66312339 0.82956916 0.85200153
 [85] 0.84338543 0.87900342 0.85317612 0.87755498 0.85162358 0.89200389
 [91] 0.85535421 0.85816222 0.88318976 0.88611089 0.83628377 0.61132790
 [97] 0.82521005 0.77285776 0.74013871 0.84631087 0.88052535 0.85779318
[103] 0.87866729 0.85162457 0.89525987 0.85679323 0.86058475 0.89708584
[109] 0.89557323 0.84575908 0.66461591 0.85137732 0.86367597 0.85322499
[115] 0.87916623 0.85818567 0.89224695 0.89515882 0.88779139 0.83642968
[121] 0.88093891 0.86223879 0.89900950 0.90101494 0.90231612 0.86447417
[127] 0.89516613 0.90324171

$IJ
                   I            J      Total
fimp      0.16018583  0.430287348 0.59047318
sconn     0.28970489  0.537115864 0.82682075
sdensep   0.02090086 -0.009919125 0.01098174
unsealden 0.09181298  0.304546072 0.39635905
fcarea    0.03609565  0.086731439 0.12282709
selev     0.21589289  0.408561821 0.62445471
amgeast   0.08864861  0.241691110 0.33033972

$I.perc
                  I
fimp      17.734548
sconn     32.073905
sdensep    2.313983
unsealden 10.164829
fcarea     3.996234
selev     23.902006
amgeast    9.814495

$gfs
 [1] -36.68245 -30.29727 -25.58116 -36.31127 -31.24099 -25.53568 -28.91701
 [8] -29.44569 -24.13048 -25.02936 -31.21361 -23.40491 -24.66242 -28.49188
[15] -23.40579 -23.17074

$IJ
              I          J      Total
fimp   2.742498  3.6426854  6.3851833
fconn  7.543709  3.5575841 11.1012927
densep 1.096251 -0.7250743  0.3711766
unseal 2.129250  3.3122091  5.4414589

$I.perc
               I
fimp   20.297197
fconn  55.830906
densep  8.113341
unseal 15.758555

hier.part documentation built on March 3, 2020, 9:07 a.m.