Intensity: Intensity function for a vector of event times

View source: R/intensity.R

IntensityR Documentation

Intensity function for a vector of event times

Description

Estimate and plot the intensity function describing the rate at which a sequence of events occurs over time.

Usage

Intensity(x, ...)

## S3 method for class 'Intensity'
plot(x, y = NULL, xlab = NULL, ylab = NULL,
     type = "l", zero.line = TRUE, ...)

Arguments

x

For Intensity: a vector of time points, given as an object of class POSIXt or Date.

For plot.Intensity: an object of class Intensity, as produced by Intensity.

y

Unused. Present to match the signature of the generic plot.

xlab

Character label for the horizontal axis. If NULL then the name of the variable passed to Intensity is used.

ylab

Character label for the vertical axis. If NULL then "Intensity" is used.

type

The type of plot to draw. Defaults to "l" (a line plot). See plot.default for other options.

zero.line

Logical. If TRUE a dotted horizontal line is drawn at zero.

...

For Intensity: extra arguments passed to density.

For plot.Intensity: extra arguments passed to plot.

Details

Intensity estimates the intensity function using a kernel density estimate (via density) of the numeric representation of the event times. Because density integrates to one, the estimate is rescaled by the number of events so that the area under the curve equals the event count. The resulting height therefore has units of events per unit time.

Value

Intensity returns an object of class Intensity. This is a density object whose y values have been rescaled to integrate to the number of events, and whose x values have been restored to the class (POSIXt or Date) of the input.

plot.Intensity is called for its side effect, which is to produce a plot on the current graphics device.

Author(s)

Steven L. Scott steve.the.bayesian@gmail.com

See Also

density

Examples

## Simulate 500 event times clustered near the middle of a one-year window.
origin <- as.Date("2020-01-01")
event.days <- rnorm(500, mean = 180, sd = 40)
event.times <- origin + event.days

intensity <- Intensity(event.times)
plot(intensity)

Boom documentation built on Sept. 16, 2026, 9:09 a.m.