[R] Negative exponential fit

Ben Bolker bbolker at gmail.com
Wed Nov 30 17:36:26 CET 2011


On 11-11-30 11:32 AM, peter dalgaard wrote:
> 
> On Nov 29, 2011, at 23:19 , Ben Bolker wrote:
> 
>> 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.
> 
> Not that this is anywhere near my areas of expertise, but wouldn't
> you want to be even more careful than that? I mean, surely the record
> time is nondecreasing, and one would expect that the time between
> records to carry information about the issue (e.g., in a stable
> situation, it should increase as a lower limit is being approached)?

  All that seems reasonable.  In addition, the lower limit is  not zero
(which my answer assumed).  However, the OP can't get a negative
exponential fit to work in the first place, so they should probably be
starting with something simple ...

  To deal with the "lower limit is not zero" problem they can just add a
parameter:

fit2 <- nls(minval+exp(logint)*exp(-r*(date-date[1])), start=...)

> 
> 
>> 
>> 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.
>> 
>> ______________________________________________ R-help at r-project.org
>> mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do
>> read the posting guide http://www.R-project.org/posting-guide.html 
>> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list