Espen Hagen Blokkdal
2013-Sep-19 16:57 UTC
[R] Fitting some data to a two-exponential expression
Hi,
I have some data that should fit to a two-exponential expression, so that
I/I[1] = a1*exp(-k1*x) + a2*exp(-k2*x)
where I have scaled by the initial value of the signal, so that a1 + a2 =1.
Using the nls-function, the nls bit of the code looks like
--------------------------------------------------------------------------
# guess-values:
T2_guess = 0.4 #[s]
# Declaring input and model for NLS-fitting
rhs <- function(T2){
exp(1)**(-tau/T2)
}
frame <- data.frame(x = tau, y = Upsilon)
# non-linear square fit.
fit = nls(Upsilon~I(rhs(T2)), data = frame, start = list(T2 = T2_guess)
)
this yields the error message:
Error in nls(Upsilon ~ I(rhs(T2)), data = frame, start = list(T2 T2_guess)) :
singular gradient
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
-----------------------------------------------------------------------------
I have no clue what this means. Anyone who can help?
--
Mvh.
Espen H. Blokkdal
[[alternative HTML version deleted]]