[R] Negative exponential fit
Ben Bolker
bbolker at gmail.com
Tue Nov 29 23:19:03 CET 2011
rch4 <rch4 <at> geneseo.edu> writes:
>
> We need help....
>
> We are doing a project for a statistical class in and we are looking at
> world record times in different running events over time. We are trying to
> fit the data with a negative exponential but we just cant seem to get a
> function that works properly.
> we have on our x-axis the date and on the y-axis the time(in seconds). So as
> you can imagine, the times have decreased and appear to be approaching a
> limit. Any ideas for a nls function that would work for us would be greatly
> appreciated.
>
> Rob
I disagree with the other solutions posted here: think you're looking
not for a distribution, but for the change over time.
You could start with
fit1 <- lm(log(time)~I(date-date[1]))
where the intercept will be the *log* of the intercept (value on
the first date) and the slope will be the exponential coefficient.
If you need to be more careful about your statistical assumptions
(e.g. if the variance appears to be homogeneous on the original
scale but not on the log scale) then something like
fit2 <- nls(exp(logint)*exp(-r*(date-date[1])),
start=...)
should work. You need to set the starting values appropriately -- the values
from the linear fit above should be pretty good.
More information about the R-help
mailing list