On Aug 26, 2010, at 1:48 PM, David Winsemius wrote:


On Aug 26, 2010, at 1:35 PM, Marlin Keith Cox wrote:

I need the parameters estimated for a non-linear equation, an example of the
data is below.


# rm(list=ls()) I really wish people would add comments to destructive pieces of code.

Time<-c( 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4,
4, 4, 5, 5, 5, 5, 5, 8, 8, 8, 8, 8)
Level<-c( 100, 110, 90, 95, 87, 60, 65, 61, 55, 57, 40, 41, 50,
47,
44, 44, 42, 38, 40, 37, 37, 35, 40, 34, 32, 20, 22, 25, 27,
29)
plot(Time,Level,pch=16)

You did not say what sort of "non-linear equation" would best suit, nor did you offer any background regarding the domain of study. There must be many ways to do this. After looking at the data, a first pass looks like this:

> lm(log(Level) ~Time )

An effort to chide me offlist for not actually saying this was a "linear model" has fallen on unreceptive ears, since it does estimate a non-linear _equation_ which was what was requested. However, this chiding has lead me to expand my repertoire of worked solutions to include an nls() solution to a Weibull equation:

> fm1 = nls(Level~ exp(-A*Time^CC) , start = list(CC=.2, A = .1), control=list(maxiter=200, minFactor=.00001), alg = 'plinear')
> fm1
Nonlinear regression model
  model:  Level ~ exp(-A * Time^CC)
   data:  parent.frame()
     CC       A    .lin
 0.7045  0.3250 96.5518
 residual sum-of-squares: 680.6

Number of iterations to convergence: 5
Achieved convergence tolerance: 2.338e-06

> plot(Level~Time)
> points(unique(Time), predict(fm1, data.frame(Time=unique(Time) ) ) , col="red", pch=4)


Maybe a Weibull model would be more appropriate.

Yes it appears to be.
--

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@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.

Reply via email to