log_zero_inflated | R Documentation |
Frequently, light exposure data need to be log-transformed. Because light exposure data frequently also contain many zero-values, adding a small value avoids losing those observations. Must be applied with care and reported.
exp_zero_inflated()
is the reverse function to log_zero_inflated()
.
log_zero_inflated(x, offset = 0.1, base = 10)
exp_zero_inflated(x, offset = 0.1, base = 10)
x |
A numeric vector |
offset |
the amount to add to |
base |
The logarithmic base, by default |
a transformed numeric vector
Johannes Zauner, Carolina Guidolin, Manuel Spitschan (2025) How to deal with darkness: Modelling and visualization of zero-inflated personal light exposure data on a logarithmic scale. bioRxiv. doi: https://doi.org/10.1101/2024.12.30.630669
c(0, 1, 10, 100, 1000, 10000) |> log_zero_inflated()
#For use in a function
sample.data.environment |>
dplyr::filter(Id == "Participant") |>
dplyr::group_by(Date = lubridate::wday(Datetime, label = TRUE, week_start = 1)) |>
dplyr::summarize(
TAT250 = duration_above_threshold(log_zero_inflated(MEDI),
Datetime,
threshold = log_zero_inflated(250)
)
)
#Calling exp_zero_inflated on data transformed with log_zero_inflated yields to the original result
c(0, 1, 10, 100, 1000, 10000) |> log_zero_inflated() |> exp_zero_inflated()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.