Learn R Programming

eventInterval (version 1.3)

EIdist: Plot the empirical and exponential distributions of values

Description

Plot the empirical distribution of a set of values.

Usage

EIdist(event_times,nbreaks=10,main="",xlab="",ylab="", xaxticks=NA,xaxlabs=NA)

Arguments

event_times
A numeric vector of times of occurrence of events.
nbreaks
The number of breaks desired (but not always delivered).
main
Title for the plot.
xlab
X axis label for the plot.
ylab
Y axis label for the plot.
xaxticks
Optional X tick mark positions.
xaxlabs
Optional X tick labels.

Value

Details

EIdist calculates the intervals between the times passed in event_times and plots a histogram of their distribution. It adds a smoothed line based on the mids and counts. It then calls fitdistr from MASS to get an estimated rate for a model exponential distribution. A second line is added to the plot for comparison with the smoothed empirical distribution.

Examples

Run this code
 ## Not run: 
#   # won't pass check due to the call to fitdistr
#   data(florida_hurr20)
#   oldloc<-Sys.setlocale("LC_TIME", "C")
#   fh_dates<-
#    as.Date(paste(florida_hurr20$day,florida_hurr20$month,
#    florida_hurr20$year,sep="-"),"%d-%B-%Y")
#   fh_days<-as.numeric(fh_dates)
#   fh_ints<-diff(fh_days)
#   fh_counts<-tabulate(florida_hurr20$year[-1]-1899,nbins=100)
#   require(MASS)
#   EIdist(fh_days,main="Empirical distribution of hurricanes",
#    xlab="Intervals in days",ylab="Frequencies")
#   Sys.setlocale("LC_TIME", oldloc)
#  ## End(Not run)

Run the code above in your browser using DataLab