Learn R Programming

HyMETT (version 1.1.3)

calc_logistic_regression: Calculate logistic regression in annual statistics with zero values

Description

Calculate logistic regression (Everitt and Hothorn, 2009) in annual statistics with zero values. A model fit to compute the probability of a zero flow annual statistic.

Usage

calc_logistic_regression(data = NULL, year, value, ...)

Value

A tibble (see tibble::tibble) with logistic regression p-value, standard error of slope, odds ratio, beginning and ending probability, and probability change. See Details.

Arguments

data

'data.frame'. Optional data.frame input, with columns containing year and value. Column names are specified as strings in the corresponding parameter. Default is NULL.

year

'numeric' vector when data = NULL, or 'character' string identifying year column name when data is specified. Year of each value in value parameter.

value

'numeric' vector when data = NULL, or 'character' string identifying value column name when data is specified. Values to calculate logistic regression on.

...

further arguments to be passed to or from stats::glm.

Details

This function is a wrapper for stats::glm(y ~ year, family = stats::binomial(link="logit") with y = 1 when value = 0 (for example a zero flow annual statistic) and y = 0 otherwise. The returned values include

p_value

Probability value of the explanatory (year) variable in the logistic model

stdErr_slope

Standard error of the regression slope (log odds per year)

odds_ratio

Exponential of the explanatory coefficient (year coefficient)

prob_beg/end

Logistic regression predicted (fitted) values at the beginning and ending year.

prob_change

Change in probability from beginning to end.

Example, an odds ratio of 1.05 represents the odds of a zero-flow year (versus non-zero) increase by a factor of 1.05 (or 5 percent).

References

Everitt, B. S. and Hothorn T., 2009, A Handbook of Statistical Analyses Using R, 2nd Ed. Boca Raton, Florida, Chapman and Hall/CRC, 376p.

See Also

Examples

Run this code
calc_logistic_regression(data = example_annual, year = "WY", value = "annual_mean")

Run the code above in your browser using DataLab