# [S] Fitting an exponential given areas beneath it

Sun, 22 Feb 1998 12:18:05 -0600

This may be less an Splus problem than one of basic math, but it does
involve fitting a model to data, one implied by the underlying
science. That's my problem--I'm not sure what S function(s) to
use to fit it. Any help would be greatly appreciated.

Consider data: catab t1 t2
1.53 0.17 1.22 where catab is amount
0.97 2.20 3.44 of a catabolite excreted
1.71 1.23 3.32 by samples of 100 flat-
2.07 0.17 2.31 worms during a time
. . . interval t1 to t2. Time
. . . zero is when food was
. . . withdrawn from worms.
0.82 1.05 2.19 The dataset has 40 rows.

I think excretion falls exponentially after food removal,
f(x) = a * b^t, {a > 0, 0 < b < 1 }.
Thus, "catab" should represent the area under f(x) between t2 and t1,
i.e., the integral
catab = a * (b^x2 - b^x1) / log(b).

I want to estimate coefficients a and b. Later, I'll use them to
sweep out effects of t1 and t2 from excretion measures in another
large dataset with yet a fourth column, "treatment". In other words,
I want to express excretion as "a", the instantaneous rate at time
zero (assuming "b" is invariant with treatment), then to correlate
"a" with treatment.

Is there a way in Splus to get maximum-likelihood (or quasi-likelihood, or
least-squares?) estimates for the coefficients a and b, that would also
allow diagnostics (goodness of fit, leverage point identification, etc.)?
I considered gam(), but the functions of x2 and x1 are not independent (in
fact they are identical!). Any suggestions? What distribution assumptions
can I safely make for my random variable "catab"?