# calculate the rate of change

I posted this on maths, but seems it would be better here :S

http://math.stackexchange.com/questions/49941/calculate-the-rate-of-change

Basically

I am trying to calculate the change frequency for a set of data. Each bit of data has the date-time it was created. I would like to say for a specific set of data the change frequency is hourly, daily, weekly, monthly or yearly.

So far I have tried getting the list of dates and get the min/max which is easy to calculate an average from which can be converted into a human readable label such as hourly, daily etc

How would i take into account the age of the last new bit of data. eg: say there were 50 dates all roughly an hour one after the other. This is hourly. but if the last one was 2 weeks ago, its not quite hourly.

In this example I am not sure myself what the frequency would be of the list (hourly, daily, weekly, monthly or yearly) so I'm looking for a bit of direction. Maybe someone here has done this before and has a good model or knows a bit more than me :)

Thanks

-

As your situation sounds a bit vague, I'd simply convert the data/times into seconds and plot the arrival times. Then, if I'm not mistaken, what you're interested in is an approximate derivative of these times. If you'd like an off-the-shelf answer using R, I recommend looking at the documentation here.

Date/time plotting is described here. With a simple R plot example:

## 100 random dates in a 10-week period
random.dates <- as.Date("2001/1/1") + 70*sort(stats::runif(100))
plot(random.dates, 1:100)
# or for a better axis labelling
plot(random.dates, 1:100, xaxt="n")
axis.Date(1, at=seq(as.Date("2001/1/1"), max(random.dates)+6, "weeks"))
axis.Date(1, at=seq(as.Date("2001/1/1"), max(random.dates)+6, "days"),
labels = FALSE, tcl = -0.2)
-