Displaying 1 result from an estimated 1 matches for "fitnegb".
Did you mean:
fiteb
2003 Aug 26
1
Getting out of an embedded function safely - use try?
...9;s well behaved before
getting into nls?
Thanks for any tips, Andy
#example
foo.one <- (1 * exp(-0.07 * 1:100) + 0.5) + rnorm(100, 0, 0.05)
foo.two <- (1 * exp(-0.000000001 * 1:100) + 0.5) + rnorm(100, 0, 0.05)
try.to.fit <- function(aVector){
toy.model <- nls(aVector ~ FitA * exp(FitNegB * 1:length(aVector)) +
FitK,
start = list( FitA = 0.75, FitNegB = -0.02, FitK = 0.4),
control = nls.control(maxiter=1000, tol=1e-05,
minFactor=1/1024))
return(fitted.values(toy.model))
}
try.to.fit(foo.one)
try.to.fit(foo.two)