Re: [R] nls problem

2020-04-03 Thread William Dunlap via R-help
:* 2. april 2020 18:50 > *Til:* Troels Ring > *Cc:* r-help mailing list > *Emne:* Re: [R] nls problem > > > > Roundoff/cancelation error: compare the following. The first is > equivalent to your function, the last to fitted(). > > > > > with(aedf, t(c

Re: [R] nls problem

2020-04-02 Thread Troels Ring
And that alone saves me. BW Troels Fra: William Dunlap Sendt: 2. april 2020 18:50 Til: Troels Ring Cc: r-help mailing list Emne: Re: [R] nls problem Roundoff/cancelation error: compare the following. The first is equivalent to your function, the last to fitted(). > with(aedf, t(cbind(1,

Re: [R] nls problem

2020-04-02 Thread J C Nash
Yes, I was waiting to see how long before it would be noticed that this is not the sort of problem for which nls() is appropriate. And I'll beat the drum again that nls() uses a simple (and generally deprecated) forward difference derivative approximation that gets into trouble a VERY high

Re: [R] nls problem

2020-04-02 Thread William Dunlap via R-help
Roundoff/cancelation error: compare the following. The first is equivalent to your function, the last to fitted(). > with(aedf, t(cbind(1, pH, pH^2) %*% round(coef(m), digits=2))) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]

Re: [R] nls problem

2020-04-02 Thread Rui Barradas
Simpler: FPG2 <- function(x, model){ as.vector(cbind(1, x, x^2) %*% coef(model)) } Hope this helps, Rui Barradas Às 12:56 de 02/04/20, Rui Barradas escreveu: Hello, Sorry, disregard my previous e-mail. Instead of your FPG function try FPG <- function(pH, model) {   coef(model)[1] +

Re: [R] nls problem

2020-04-02 Thread Rui Barradas
Hello, Sorry, disregard my previous e-mail. Instead of your FPG function try FPG <- function(pH, model) { coef(model)[1] + coef(model)[2]*pH + coef(model)[3]*pH^2 } FPG(aedf$pH, m) fitted(m) Hope this helps, Rui Barradas Às 12:30 de 02/04/20, Rui Barradas escreveu: Hello, Tip: in a

Re: [R] nls problem

2020-04-02 Thread Rui Barradas
Hello, Tip: in a formula, pH^2 = pH*pH is an interaction. pH^2 = pH*pH = pH + pH + pH:pH = pH Try I(pH^2) Hope this helps, Rui Barradas Às 12:07 de 02/04/20, Troels Ring escreveu: Dear friends - I'm on Win10 with R 6.3.1 and have a very simple problem with nls which apparently gives a

[R] nls problem

2020-04-02 Thread Troels Ring
Dear friends - I'm on Win10 with R 6.3.1 and have a very simple problem with nls which apparently gives a decent fit to the parable below, even without starting values. But when I then think I know the meaning of the three parameters a, b, and d it goes very wrong. I guess I am again overlooking

[R] nls problem with iterations

2013-01-03 Thread Karine HEERAH
Hi, I am using the nls function and it stops because the number of iterations exceeded 50, but i used the nls.control argument to allow for 500 iterations. Do you have any idea why it's not working? fm1 - nls(npe ~ SSgompertz(npo, Asym, b2, b3), data=f,control=nls.control(maxiter=500))

Re: [R] nls problem with iterations

2013-01-03 Thread Bert Gunter
Would you show the exact message you get please. -- Bert On Thu, Jan 3, 2013 at 5:22 AM, Karine HEERAH karine.hee...@locean-ipsl.upmc.fr wrote: Hi, I am using the nls function and it stops because the number of iterations exceeded 50, but i used the nls.control argument to allow for 500

Re: [R] nls problem: singular gradient

2012-07-12 Thread Jonas Stein
On 07/12/2012 01:39 AM, Duncan Murdoch wrote: On 12-07-11 2:34 PM, Jonas Stein wrote: Take a look at the predicted values at your starting fit: there's a discontinuity at 0.4, which sure makes it look as though overflow is occurring. I'd recommend expanding tanh() in terms of exponentials and

Re: [R] nls problem: singular gradient

2012-07-12 Thread peter dalgaard
On Jul 11, 2012, at 20:34 , Jonas Stein wrote: Take a look at the predicted values at your starting fit: there's a discontinuity at 0.4, which sure makes it look as though overflow is occurring. I'd recommend expanding tanh() in terms of exponentials and rewrite the prediction in a way

[R] nls problem: singular gradient

2012-07-12 Thread John C Nash
) -- Best, JN On 07/12/2012 06:00 AM, r-help-requ...@r-project.org wrote: From: Jonas Stein n...@jonasstein.de To: r-h...@stat.math.ethz.ch Subject: [R] nls problem: singular gradient Message-ID: e8h0d9-ao4@news.jonasstein.de Content-Type: text/plain Why fails

[R] nls problem: singular gradient

2012-07-11 Thread Jonas Stein
Why fails nls with singular gradient here? I post a minimal example on the bottom and would be very happy if someone could help me. Kind regards, ### # define some constants smallc - 0.0001 t - seq(0,1,0.001) t0 - 0.5 tau1 - 0.02 # generate yy(t) yy - 1/2 * ( 1- tanh((t - t0)/smallc)

Re: [R] nls problem: singular gradient

2012-07-11 Thread Duncan Murdoch
On 11/07/2012 11:04 AM, Jonas Stein wrote: Why fails nls with singular gradient here? I post a minimal example on the bottom and would be very happy if someone could help me. Take a look at the predicted values at your starting fit: there's a discontinuity at 0.4, which sure makes it look as

Re: [R] nls problem: singular gradient

2012-07-11 Thread Jonas Stein
Take a look at the predicted values at your starting fit: there's a discontinuity at 0.4, which sure makes it look as though overflow is occurring. I'd recommend expanding tanh() in terms of exponentials and rewrite the prediction in a way that won't overflow. Duncan Murdoch Hi Duncan,

Re: [R] nls problem: singular gradient

2012-07-11 Thread Duncan Murdoch
On 12-07-11 2:34 PM, Jonas Stein wrote: Take a look at the predicted values at your starting fit: there's a discontinuity at 0.4, which sure makes it look as though overflow is occurring. I'd recommend expanding tanh() in terms of exponentials and rewrite the prediction in a way that won't

[R] nls problem

2012-07-04 Thread John C Nash
den hoff j.van_den_h...@hzdr.de To: r-help@r-project.org Subject: [R] nls problem Message-ID: op.wgvcolzs24o...@marco.fz-rossendorf.de Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes hi list, used versions: 2.12.1 and 2.14.0 under ubuntu and macosx. I

[R] nls problem

2012-07-03 Thread joerg van den hoff
hi list, used versions: 2.12.1 and 2.14.0 under ubuntu and macosx. I recently stumbled over a problem with `nls', which occurs if the model is not specified explicitly but via an evaluation of a 'call' object. simple example:

Re: [R] nls problem with R

2011-05-08 Thread sterlesser
I am sorry,Andrew,I don't get you. Please forgive my poor English. -- View this message in context: http://r.789695.n4.nabble.com/nls-problem-with-R-tp3494454p3508131.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] nls problem with R

2011-05-08 Thread sterlesser
Thanks Mike. Your suggestion is really helpful.I did with the your instruction , it really works out. What's more,can you use this package http://cran.r-project.org/web/packages/minpack.lm/index.html it use Levenberg-Marquardt algorithm. Can this package do with four parameters? Thanks again --

Re: [R] nls problem with R

2011-05-05 Thread sterlesser
the dataset's form is changed after my post so I repost it here t 0 0.3403 0.4181 0.4986 0.7451 1.0069 1.5535 1.8049 2.4979 6.4903 13.5049 27.5049 41.5049 V(t) 6.053078443 5.56937391 5.45484486 5.193124598 4.31386722 3.645422269 3.587710965 3.740362689 3.699837726 2.908485019 1.888179494

Re: [R] nls problem with R

2011-05-05 Thread sterlesser
ID1 ID2 t V(t) 1 1 0 6.053078443 2 1 0.3403 5.56937391 3 1 0.4181 5.45484486 4 1 0.4986 5.193124598 5 1 0.7451 4.31386722 6 1 1.0069 3.645422269 7 1 1.5535 3.587710965 8

Re: [R] nls problem with R

2011-05-05 Thread Andrew Robinson
Apologies, but I don't see a question here ... am I missing something obvious? Andrew On Thu, May 05, 2011 at 01:20:33AM -0700, sterlesser wrote: ID1 ID2 t V(t) 1 1 0 6.053078443 2 1 0.3403 5.56937391 3 1 0.4181 5.45484486 4

Re: [R] nls problem with R

2011-05-05 Thread Mike Marchywka
Date: Thu, 5 May 2011 01:20:33 -0700 From: sterles...@hotmail.com To: r-help@r-project.org Subject: Re: [R] nls problem with R ID1 ID2 t V(t) 1 1 0 6.053078443 2 1 0.3403 5.56937391 3 1 0.4181 5.45484486 4 1 0.4986 5.193124598 5 1 0.7451

[R] nls problem with R

2011-05-04 Thread sterlesser
the original data are V2 =c(371000,285000 ,156000, 20600, 4420, 3870, 5500 ) T2=c( 0.3403 ,0.4181 ,0.4986 ,0.7451 ,1.0069 ,1.553) nls2=nls(V2~v0*(1-epi+epi*exp(-cl*(T2-t0))),start=list(v0=10^7,epi=0.9,cl=6.2,t0=8.7)) after execution error occurs as below

Re: [R] nls problem with R

2011-05-04 Thread Andrew Robinson
The fact that T2 and V2 are of different lengths seems like a likely culprit. Other than that, you need to find start points that do not lead to a singular gradient. There are several books that provide advice on obtaining initial parameter estimates for non-linear models. Google Books might

Re: [R] nls problem with R

2011-05-04 Thread Rubén Roa
-project.org [mailto:r-help-boun...@r-project.org] En nombre de Andrew Robinson Enviado el: miércoles, 04 de mayo de 2011 9:15 Para: sterlesser CC: r-help@r-project.org Asunto: Re: [R] nls problem with R The fact that T2 and V2 are of different lengths seems like a likely culprit. Other than

Re: [R] nls problem with R

2011-05-04 Thread sterlesser
Thanks Ruben. Your suggestion about more deeper analysis about the model itself is really helpful. I am trying out some new initial values based on the analysis of the special T2 in the model. -- View this message in context:

Re: [R] nls problem with R

2011-05-04 Thread sterlesser
Thanks Andrew. I am sorry for some typos that I omit some numbers of T2. Based on your suggestion,I think the problem is in the initial values. And I will read more theory about the non-linear regression. -- View this message in context:

Re: [R] nls problem with R

2011-05-04 Thread Ravi Varadhan
-project.org] On Behalf Of sterlesser Sent: Wednesday, May 04, 2011 10:08 AM To: r-help@r-project.org Subject: Re: [R] nls problem with R Thanks Andrew. I am sorry for some typos that I omit some numbers of T2. Based on your suggestion,I think the problem is in the initial values. And I will read more

Re: [R] nls problem with R

2011-05-04 Thread Mike Marchywka
Date: Wed, 4 May 2011 07:07:44 -0700 From: sterles...@hotmail.com To: r-help@r-project.org Subject: Re: [R] nls problem with R Thanks Andrew. I am sorry for some typos that I omit some numbers of T2. Based on your suggestion,I think the problem is in the initial values. And I will read