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.
calc_logistic_regression(data = NULL, year, 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.
'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.
'numeric' vector when data = NULL, or 'character' string identifying year column
name when data is specified. Year of each value in value parameter.
'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.
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_valueProbability value of the explanatory (year) variable in the logistic model
stdErr_slopeStandard error of the regression slope (log odds per year)
odds_ratioExponential of the explanatory coefficient (year coefficient)
prob_beg/endLogistic regression predicted (fitted) values at the beginning and ending year.
prob_changeChange 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).
Everitt, B. S. and Hothorn T., 2009, A Handbook of Statistical Analyses Using R, 2nd Ed. Boca Raton, Florida, Chapman and Hall/CRC, 376p.
calc_logistic_regression(data = example_annual, year = "WY", value = "annual_mean")
Run the code above in your browser using DataLab