[R] exponential model in R
Ben Bolker
bbolker at gmail.com
Sun Feb 10 20:14:42 CET 2013
Please continue the conversation on-list.
(1) Various things can happen, but in particular you need to identify
good starting parameters. 'a' should be approximately the x-intercept, b
should be approximately the slope of log(proc) as cls changes.
(2) I don't know what "impossible to put it in the plot with lines
command" means.
(3) Please read the posting guide and this URL:
http://tinyurl.com/reproducible-000 about asking reproducible questions.
You should also try googling "r nonlinear regression examples" and read
some of the material you find ...
On 13-02-10 01:51 PM, catalin roibu wrote:
> Dear Ben Bolker,
>
> I don't know what is happening wen I run this script: n1 <-
> nls(proc~a*exp(b*cls),start=list(a=4,b=-0.01),data=dpoz)
> Error in nls(proc ~ a * exp(b * cls), start = list(a = 4, b = -0.01), :
> singular gradient
>
> Please help me to solve this problem!
>
> Thank you!
>
>
> On 10 February 2013 18:17, catalin roibu <catalinroibu at gmail.com
> <mailto:catalinroibu at gmail.com>> wrote:
>
> Dear Ben,
> Thank you for your help!
> I have two problems if I run the script. If I use the first equation
> I have this error: Error in nls(proc ~ a * exp(b * cls), start =
> list(a = 4, b = -0.01), :
> singular gradient
>
> If I use the second equation is OK but is impossible to put it in
> the plot with lines command.
>
> Thank you!
>
>
> On 10 February 2013 17:10, Ben Bolker <bbolker at gmail.com
> <mailto:bbolker at gmail.com>> wrote:
>
> catalin roibu <catalinroibu <at> gmail.com <http://gmail.com>>
> writes:
>
> >
> > Dear R users,
> > I don't know how to compute an exponential model like this:
> > proc=a*exp(b*cls), or proc=a*exp(b*cls)+c*exp(d*cls). Please
> help me to
> > solve this problem!
> >
> > Thank you!
> >
> > My data is:
>
> This still doesn't make much sense/have much context,
> but I'll make some guesses.
>
> dat <- read.table(textConnection("
> proc cls
> 0.5 452.616206 0.5
> 1 255.864021 1.0
> 1.5 150.885316 1.5 <tel:150.885316%201.5>
> 2 86.289600 2.0 <tel:86.289600%202.0>
> 2.5 56.321559 2.5 <tel:56.321559%202.5>
> 3 39.504444 3.0
> 3.5 25.570308 <tel:3.5%2025.570308> 3.5
> 4 5.382726 4.0
> "),header=TRUE)
>
> with(dat,plot(cls~proc))
>
> I suspect that what you want to *fit* these models.
>
> n1 <- nls(cls~a*exp(b*proc),start=list(a=4,b=-0.01),data=dat)
> n2 <- nls(cls~SSbiexp(proc,a,logb,c,logd),data=dat)
>
> lines(dat$proc,predict(n1))
> lines(dat$proc,predict(n2),col=2)
>
> ______________________________________________
> R-help at r-project.org <mailto: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.
>
>
>
>
> --
> ---
> Catalin-Constantin ROIBU
> Forestry engineer, PhD
> Forestry Faculty of Suceava
> Str. Universitatii no. 13, Suceava, 720229, Romania
> office phone +4 0230 52 29 78, ext. 531
> <tel:%2B4%200230%2052%2029%2078%2C%20ext.%20531>
> mobile phone +4 0745 53 18 01 <tel:%2B4%200745%2053%2018%2001>
> +4 0766 71 76 58 <tel:%2B4%200766%2071%2076%2058>
> FAX: +4 0230 52 16 64 <tel:%2B4%200230%2052%2016%2064>
> silvic.usv.ro <http://silvic.usv.ro>
>
>
>
>
> --
> ---
> Catalin-Constantin ROIBU
> Forestry engineer, PhD
> Forestry Faculty of Suceava
> Str. Universitatii no. 13, Suceava, 720229, Romania
> office phone +4 0230 52 29 78, ext. 531
> mobile phone +4 0745 53 18 01
> +4 0766 71 76 58
> FAX: +4 0230 52 16 64
> silvic.usv.ro <http://silvic.usv.ro>
More information about the R-help
mailing list