Learn R Programming

hier.part (version 1.0-6)

all.regs: Goodness of Fit Measures for a Regression Hierarchy

Description

Calculates goodness of fit measures for regressions of a single response variable to all combinations of N predictor variables

Usage

all.regs(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"),
         print.vars = FALSE, ...)

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".

print.vars

if FALSE, the function returns a vector of goodness-of-fit measures. If TRUE, a data frame is returned with first column listing predictor variable combinations and the second column listing goodness-of-fit measures.

...

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

Value

gfs

If print.vars is FALSE, a vector of goodness of fit measures for all combinations of predictors in the hierarchy or, if print.vars is TRUE, a data frame listing all combinations of predictor variables in the first column in ascending order, and the corresponding goodness of fit measure for the model using those variables

Details

This function calculates goodness of fit measures for the entire hierarchy of models using all combinations of N predictors, and returns them as an ordered list ready for input into the function partition.

References

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.

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 southeastern Australia. Biodiversity and Conservation 13, 781--793.

See Also

hier.part, partition, rand.hp

Examples

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

    data(urbanwq)
    env <- urbanwq[,2:8]
    all.regs(urbanwq$lec, env, fam = "gaussian", gof = "Rsqu",
             print.vars = TRUE)

    #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]
    all.regs(amphipod$australis, env1, fam = "binomial",
             gof = "logLik", print.vars = TRUE)
# }

Run the code above in your browser using DataLab