Skip to content

Instantly share code, notes, and snippets.

Zachary M. Jones zmjones

Block or report user

Report or block zmjones

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@zmjones
zmjones / decay.R
Last active Oct 12, 2015
time since event and decaying cumulative sums for binary time series
View decay.R
decay <- function(yvar, d) {
# yvar: a binary variable
# d: number of periods
# returns: the cumulative sum of yvar at each point
# where each addition to the count decays away after d periods
yvar[is.na(yvar)] <- 0
run <- cumsum(yvar)
tvar <- seq_along(yvar)
run <- 0
sum <- 0
You can’t perform that action at this time.