# [R] non linear equation

Blaser Nello nblaser at ispm.unibe.ch
Wed Apr 10 16:39:14 CEST 2013

```I would suggest to try different starting values. The following works
for instance:
n2<-nls(proc~f(cls,a,b,c,d),data=bline,start=list(a=1000,b=-1,c=4,d=1),t
race=TRUE)

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Jorge I Velez
Sent: Mittwoch, 10. April 2013 13:35
To: catalin roibu
Cc: R mailing list
Subject: Re: [R] non linear equation

Please do not forget to CC the list to increase your chances of getting
help.  --JIV

On Wed, Apr 10, 2013 at 9:31 PM, catalin roibu
<catalinroibu at gmail.com>wrote:

> Hello!
> I try to compute the double exponential function this code:
> f<-function(cls,a,b,c,d)a*exp(cls*b)+c*exp(cls*d)
>
> n2<-nls(proc~f(cls,a,b,c,d),data=bline,start=list(a=600,b=-.1,c=4,d=-.
> 1),trace=TRUE)
> proc~f(cls,a,b,c,d)
>
> but don't work!
>
> Thanks!
>
>
>
> On 10 April 2013 12:47, catalin roibu <catalinroibu at gmail.com> wrote:
>
>> Hello!
>> I try to nls and I compute a simple exponential equation, but the
>> problem in nls is to anticipate the regression coefficients.
>>
>>
>> On 10 April 2013 12:19, Jorge I Velez <jorgeivanvelez at gmail.com>
wrote:
>>
>>> Dear Catalin,
>>>
>>> You can look at ?nls.
>>>
>>> Alternatively, you could also consider a linear model as follows,
>>> where "d" is your data:
>>>
>>> with(d, plot(cls, proc, las = 1))
>>>
>>> # linear model
>>> fit <- lm(proc ~ I(1/cls) + I((1/cls)^2), data = d)
>>> summary(fit)
>>>
>>> # plotting
>>> with(d, plot(cls, proc, las = 1))
>>> grid <- seq(min(d\$cls), max(d\$cls), length = 1000) points(grid,
>>> predict(fit, data.frame(cls = grid)), type = "l", col = 2)
>>>
>>> HTH,
>>> Jorge.-
>>>
>>>
>>>
>>>
>>>  On Wed, Apr 10, 2013 at 7:01 PM, catalin roibu
<catalinroibu at gmail.com>wrote:
>>>
>>>>  Hello all!
>>>>
>>>>  I have a problem with a double exponential equation.
>>>> this are my data's>
>>>> structure(list(proc = c(1870.52067384719, 766.789388745793,
>>>> 358.701545859122, 237.113777545511, 43.2726259059654,
>>>> 148.985133316262, 92.6242882655781, 88.4521557193262,
>>>> 56.6404686159112, 27.0374477259404, 34.3347291080268,
>>>> 18.3226992991316, 15.2196612445747, 5.31600719692165,
>>>> 16.7015717397302, 16.3923389973684, 24.2702542054496,
>>>> 21.247247993673, 18.3070717608672, 2.8811892177331,
>>>> 3.18018869564679, 8.74204132937479, 7.11596966047229 ), cls =
>>>> c(0.25, 0.5, 0.75, 1, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6,
>>>> 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10)), .Names = c("proc", "cls"),
>>>> row.names = c("0.25", "0.5", "0.75", "1", "11", "1.5", "2", "2.5",
>>>> "3", "3.5", "4", "4.5", "5", "5.5", "6", "6.5", "7", "7.5", "8",
>>>> "8.5", "9", "9.5", "10"), class = "data.frame") I want to compute a
double exponential equation like this:
>>>> proc=a*exp(b*class)+c*exp(d*class)
>>>> or
>>>> proc=a*exp(b*class)+c*class
>>>> or a power, logarithmic equation.
>>>> Is there a possibility to calculate R squared for each model?
>>>>
>>>> Thank you!
>>>>
>>>> --
>>>> ---
>>>> Catalin-Constantin ROIBU
>>>> Lecturer PhD, Forestry engineer
>>>> 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
>>>>
>>>>         [[alternative HTML version deleted]]
>>>>
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>
>>>
>>>
>>
>>
>> --
>> ---
>> Catalin-Constantin ROIBU
>> Lecturer PhD, Forestry engineer
>> 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
>>
>
>
>
> --
> ---
> Catalin-Constantin ROIBU
> Lecturer PhD, Forestry engineer
> 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
>

[[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help