Questions tagged [nls]

nls refers to nonlinear least-squares and is a function in R that allows to estimate the parameters of a nonlinear model.

nls should not be confused with nls-lang which is an environment variable for Oracle databases.

670 questions
0
votes
0 answers

get error of nonlinear least square in r

I got this error Error in qr(.swts * attr(rhs, "gradient")) : dims [product 6] do not match the length of object [81] I was replace the starting value but still get error. Here is my code: x=c(30,110) y=c(0.000760289, 0.000800320, 0.000830345,…
0
votes
0 answers

Nonlinear least square in r

Check please, there is a good fit or not. I have two vectors here: x=c(30,110) y=c(0.000760289, 0.000800320, 0.000830345, 0.000840353, 0.000860370, 0.000910414, 0.000990490, 0.001090594, 0.001200721, 0.001350912, 0.001531172, 0.001751533,…
Aesha
  • 1
0
votes
0 answers

Nonlinear Model Fit with Integral - R - General Approach

Trying to fit a three mechanism non-linear membrane fouling model which includes an integral expression. Tried to extend Example 1 from nls.lm {minpack.lm} help page. Question: How would I modify Example 1 to include an integral expression? Made…
VincePi
  • 45
  • 1
  • 8
0
votes
1 answer

Error in nlsModel: singular gradient matrix at initial parameter estimates

I encountered this nls singular matrix problems in some real data test, also tried nlsLM, but I always get the same error. Some existing solutions in the stackoverflow says the initial parameters are not ideal enough. Then I created a test dataset…
MangooSaSa
  • 3,411
  • 3
  • 14
  • 16
0
votes
0 answers

add line to nls fit and plot

I am having problems adding a line to one scatter plot. My data is fit to an exponential model. I used nls to get coefficients: fit <- nls(volumen ~ bo+ exp(b1*dap), data= df, start = list(bo=0, b1=55)) Later I used plot and lines commands to…
Rodrigo_BC
  • 161
  • 11
0
votes
1 answer

How to incorporate mapply with nlsLM in R?

I am trying to fit my modely~exp((a*x1+b*x2+c)^d)+f but I getting an error as I am not sure how to incorporate mapply with nlsLM from Package:minpack.lm ERROR: Error in fn(par, ...) : unused arguments (x1 = c(0.203114295490632,…
Barry
  • 739
  • 1
  • 8
  • 29
0
votes
1 answer

error with nls function in r with almost the same data

I have two tables with very similar data and I want to fit a model: ###first data x1 <- c(0.271237802,0.253595465,0.299072793,0.355537802, 0.335295465,0.365922793,0.476437802,0.464095465,0.482172793) y1 <-…
0
votes
1 answer

Is there a way to mimic the nls nls.control(warnOnly=TRUE) when using nlsLM?

I'm fitting a non-linear model to a large number (1000s) of data curves. I expect that the model cannot be fit to some of the curves, so when going through the data set I'd like to ignore those few cases for which nls returns an error and continue.…
Fleetboat
  • 189
  • 7
0
votes
1 answer

R Programming nls(): confint() with error singular gradient

The following indicates the code and output: library(minpack.lm) #Levenberg-Marquardt Nonlinear Least-Squares algorithm (with support for lower and upper parameter bounds) library(ggplot2) #Sophisticated combination of base and lattice…
0
votes
1 answer

nls2 fitting in R (get back calculated values)

I am using the nls2 package to do a fit. The fit is correct but how do I get back just the calculated values of the predicted variables? The formula: fit <- nls2(Trans ~ t - (h * W ^ 2 / ((WLn - x0) ^ 2 + W ^ 2)), data = siteData, start =…
user3646105
  • 2,459
  • 4
  • 14
  • 18
0
votes
1 answer

R: Plotting fitted model with the confident intervals for each predicted values in x

How could I plot the fitted model with the confident intervals for each predicted value (in x= 5, 10, 15, 20, 25, 30, 35) ? For the next dataset df<-data.frame( x = rep(c( 5, 10, 15, 20, 25, 30, 35), each=4 ), y = c(0.2, 1.1, 1.5, 0.9, …
Juanchi
  • 1,147
  • 2
  • 18
  • 36
0
votes
0 answers

Issue with non-linear least squares regression

I've been experiencing an issue when trying to estimate a model using the 'nls' function. I am trying to estimate the parameters (i.e. the aj's for j=0,1,...,9) in the following equation: log(y) = log(a0 + a1*x1 + a2*x2 + a3*x3 + a4*(x1)^2 +…
Larry
  • 45
  • 5
0
votes
0 answers

R: nlsLM error when inside a large loop

I'm quite new in R and in StackOverflow. I'm trying to make a large bootstrap using a nlsLM inside a for loop. The nlsLM must to run about 1000 or 1500 times, each loop use about 70% of my data ordered randomly. If I run my code about 100 times it…
José Ricardo
  • 301
  • 1
  • 2
  • 7
0
votes
0 answers

How to fix 'singular gradient matrix at initial parameter estimates' error

I have two vectors: y: [1] 1889 1528 1213 1009 912 777 783 708 644 716 707 644 634 624 625 [16] 574 616 569 573 577 565 585 528 572 511 494 555 491 520 518 [31] 476 454 470 440 450 465 436 403 448 473 429 …
cohara
  • 111
  • 3
  • 19
0
votes
1 answer

another: "singular gradient matrix at initial parameter estimates"

I'm trying to fit a Gompertz curve with the nls function, which always gives me the "singular gradient" error. I know a lot of questions are devoted to this error, but I still can't figure out my problem. I tried out multiple formula variations,…
Wave
  • 1,216
  • 1
  • 9
  • 22