Re: [R] problem with nls....

2019-03-23 Thread Ivan Krylov
On Fri, 22 Mar 2019 12:29:14 + akshay kulkarni wrote: > How do I get the gradient, Hessian, and the jacobian of the > objective function created by call to the nls? nls() return value is a list containing an entry named `m`, which is an object of type "nlsModel". It doesn't seem to be

Re: [R] problem with nls....

2019-03-22 Thread Martin Maechler
> Ivan Krylov > on Thu, 21 Mar 2019 18:36:20 +0300 writes: > One of the assumptions made by least squares method is that the > residuals are independent and normally distributed with same parameters > (or, in case of weighted regression, the standard deviation of the

Re: [R] problem with nls....

2019-03-21 Thread akshay kulkarni
KULKARNI From: Ivan Krylov Sent: Thursday, March 21, 2019 9:06 PM To: r-help@r-project.org Cc: akshay kulkarni Subject: Re: [R] problem with nls One of the assumptions made by least squares method is that the residuals are independent and normally distributed

Re: [R] problem with nls....

2019-03-21 Thread Ivan Krylov
One of the assumptions made by least squares method is that the residuals are independent and normally distributed with same parameters (or, in case of weighted regression, the standard deviation of the residual is known for every point). If this is the case, the parameters that minimize the sum

[R] Problem with nls function

2015-11-16 Thread roberto marrone
Dear all, I have a problem using the R finction nls. I am trying to perform an optimisation of the volatility parameter in the Black and Scholes formula. In the function nls I wrote as a formula the call option price with the only unknown parameter the volatility that I called theta. The

Re: [R] Problem with nls function

2015-11-16 Thread William Dunlap
Instead of giving nls() start=0.01, give it a named vector of parameters, start=c(theta=0.01). Bill Dunlap TIBCO Software wdunlap tibco.com On Mon, Nov 16, 2015 at 6:19 AM, roberto marrone wrote: > Dear all, > > I have a problem using the R finction nls. I am trying

[R] Problem with nls regression fit

2012-10-01 Thread Gyanendra Pokharel
Hi all, I got following problem in fitting the data. Any kind of suggestions are welcome beta - 3.5 d - seq(0.1,62.5,0.1) y - exp(-beta*d) y1 - y x - read.table(epidist.txt, header = TRUE) data.nls - as.data.frame(cbind(y1,x)) #attach(data.nls) nls.fit - nls(y1~dist,data.nls) Error in

Re: [R] Problem with nls regression fit

2012-10-01 Thread Jean V Adams
You have not specified a nonlinear formula. There are no parameters to estimate in the formula you provide, y1~dist. What is the nonlinear relation you are trying to fit? Look at the help file for nls to see some examples worked. ?nls Jean Gyanendra Pokharel gyanendra.pokha...@gmail.com

[R] problem with nls starting values

2012-09-27 Thread Benedikt Gehr
Hi I would like to fit a non-linear regression to the follwoing data: quantiles-c(seq(.05,.95,0.05)) slopes-c( 0.00e+00, 1.622074e-04 , 3.103918e-03 , 2.169135e-03 , 9.585523e-04 ,1.412327e-03 , 4.288103e-05, -1.351171e-04 , 2.885810e-04 ,-4.574773e-04 , -2.368968e-03, -3.104634e-03,

Re: [R] problem with nls starting values

2012-09-27 Thread Bert Gunter
My guess: You probably are overfitting your data. A straight line does about as well as anything except for the 3 high leverage points, which the minimization is probably having trouble with. -- Bert On Thu, Sep 27, 2012 at 10:43 AM, Benedikt Gehr benedikt.g...@ieu.uzh.ch wrote:

Re: [R] problem with nls starting values

2012-09-27 Thread Benedikt Gehr
thanks for your reply I agree that an lm model would fit just as well, however the expectation from a mechanistic point of view would be a non-linear relationship. Also when I simulate data as in y_val-115-118*exp(-0.12*(seq(1,100)+rnorm(100,0,0.8))) x_val-seq(1:100) plot(y_val~x_val)

Re: [R] problem with nls starting values

2012-09-27 Thread Berend Hasselman
On 27-09-2012, at 21:15, Benedikt Gehr benedikt.g...@ieu.uzh.ch wrote: thanks for your reply I agree that an lm model would fit just as well, however the expectation from a mechanistic point of view would be a non-linear relationship. Also when I simulate data as in

Re: [R] problem with nls starting values

2012-09-27 Thread Benedikt Gehr
now I feel very silly! I swear I was trying this for a long time and it didn't work. Now that I closed R and restarted it it works also on my machine. So is the only problem that my model is overparametrized with the data I have? however shouldn't it be possible to fit an nls to these data?

Re: [R] problem with nls starting values

2012-09-27 Thread Bert Gunter
On Thu, Sep 27, 2012 at 12:43 PM, Benedikt Gehr benedikt.g...@ieu.uzh.ch wrote: now I feel very silly! I swear I was trying this for a long time and it didn't work. Now that I closed R and restarted it it works also on my machine. So is the only problem that my model is overparametrized with

Re: [R] problem with nls starting values

2012-09-27 Thread Ben Bolker
Bert Gunter gunter.berton at gene.com writes: On Thu, Sep 27, 2012 at 12:43 PM, Benedikt Gehr benedikt.gehr at ieu.uzh.ch wrote: now I feel very silly! I swear I was trying this for a long time and it didn't work. Now that I closed R and restarted it it works also on my machine. So

Re: [R] problem with nls starting values

2012-09-27 Thread Bert Gunter
Good point, Ben. I followed up my earlier reply offline with a brief note to Benedikt pointing out that No was the wrong answer: maybe, maybe not would have been better. Nevertheless, the important point here is that even if you do get convergence, the over-parameterization means that the

Re: [R] problem with nls starting values

2012-09-27 Thread Ben Bolker
On 12-09-27 05:34 PM, Bert Gunter wrote: Good point, Ben. I followed up my earlier reply offline with a brief note to Benedikt pointing out that No was the wrong answer: maybe, maybe not would have been better. Nevertheless, the important point here is that even if you do get

Re: [R] Problem with 'nls' fitting logistic model (5PL)

2012-05-03 Thread Michal Figurski
Bert, Thank you for your thoughts. I can assure you I have plotted the data back and forth many times, and that overfitting has nothing to do with it. This is not a _statistical_ problem, but a _technical_ problem. Something that works well in ANY reliable statistical software doesn't work

Re: [R] Problem with 'nls' fitting logistic model (5PL)

2012-05-03 Thread Keith Jewell
?nls.control fit- nls(MFI~a + b/((1+(nom/c)^d)^f), data=x, weights=x$weights, + start=c(a=100, b=1, c=100, d=-1, f=1), control=nls.control(warnOnly=TRUE)) Warning message: In nls(MFI ~ a + b/((1 + (nom/c)^d)^f), data = x, weights = x$weights, : step factor 0.000488281 reduced below

Re: [R] Problem with 'nls' fitting logistic model (5PL)

2012-05-03 Thread Bert Gunter
Thanks, Keith. I failed to cc the following reply to John Nash to the list. Your email persuaded me that it might be useful to do so. None of this changes the fact that the model is overfitted. You may be able to get convergence to some set of parameter estates, but they won't have much meaning

Re: [R] Problem with 'nls' fitting logistic model (5PL)

2012-05-03 Thread Gabor Grothendieck
On Wed, May 2, 2012 at 3:32 PM, Michal Figurski figur...@mail.med.upenn.edu wrote: Dear R-Helpers, I'm working with immunoassay data and 5PL logistic model. I wanted to experiment with different forms of weighting and parameter selection, which is not possible in instrument software, so I

[R] Problem with 'nls' fitting logistic model (5PL)

2012-05-02 Thread Michal Figurski
Dear R-Helpers, I'm working with immunoassay data and 5PL logistic model. I wanted to experiment with different forms of weighting and parameter selection, which is not possible in instrument software, so I turned to R. I am using R 2.14.2 under Win7 64bit, and the 'nls' library to fit the

Re: [R] Problem with 'nls' fitting logistic model (5PL)

2012-05-02 Thread Bert Gunter
Plot the data. You're clearly overfitting. (If you don't know what this means or why it causes the problems you see, try a statistical help list or consult your local statistician). -- Bert On Wed, May 2, 2012 at 12:32 PM, Michal Figurski figur...@mail.med.upenn.edu wrote: Dear R-Helpers,

Re: [R] problem with nls function

2010-01-27 Thread Carl Witthoft
quote From: hammadi jbeli hammadi.jbeli_at_gmail.com Date: Tue, 26 Jan 2010 23:40:47 +0100 I have used R formulation style and I found this in some R documentations. /quote Sorry, that makes no sense. I would recommend you go back to your original dataset and pick a very small subset of

Re: [R] problem with nls function

2010-01-26 Thread hammadi jbeli
I have used R formulation style and I found this in some R documentations. On Tue, Jan 26, 2010 at 4:12 AM, Walmes Zeviani walmeszevi...@hotmail.comwrote: I supose you are following the SAS formulation style. R has a different formulation style, such as: da - expand.grid(A=factor(1:3),

[R] problem with nls function

2010-01-25 Thread hammadi jbeli
Dear R users, I have a response variable in a csv file called y and a matrix of predictor variables in a csv file called mat. I have used the function nls I have specified the nonlinear relation between these variable.The code I have witten is called Rprog which begins with the phrase:

Re: [R] problem with nls function

2010-01-25 Thread Walmes Zeviani
I supose you are following the SAS formulation style. R has a different formulation style, such as: da - expand.grid(A=factor(1:3), x=1:10) da$y - as.numeric(da$A)*da$x/(1.2+da$x)+rnorm(da$x, 0, 0.1) m0 - nls(y~Asym[A]*x/(Time[A]+x), data=da, start=list(Asym=c(1,2,3), Time=c(1,1,1)))

[R] Problem with nls function

2010-01-25 Thread hammadi jbeli
Dear R users, I have a response variable in a csv file called y and a matrix of predictor variables in a csv file called mat. I have used the function nls I have specified the nonlinear relation between these variable.The code I have witten is called Rprog which begins with the phrase: