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

Levendberg-Marquard vs Port nls

Im having some problems to understand why I'm getting an error Convergence failure: false convergence (8) when I run a non linear fitting using nls along with the port algorithm, which allows me to set boundaries. However, when I run the same…
0
votes
0 answers

How to fit and plot a double first-order exponential decay equation in R?

I'm trying to fit and plot (using ggplot2) a double first-order exponential decay equation "y=[a1exp(-k1t)]+[a2exp(-k2t)]" to my experimental data (radioactive decay) using the nls function but I unable since the following warning messages are…
0
votes
2 answers

How to fit a data set to an specific function by trial and error or a better specific alternative in R?

I have a data set and I want to adjust to the following function and find the parameters a and b: I tried the nonlinear least squares approach, however, I'd like to try by trial and error, using a vector with values for a, and another for b, then…
Daniel Valencia C.
  • 2,159
  • 2
  • 19
  • 38
0
votes
1 answer

How to use nls() to fit multiple constants in exponential decay model?

I am dealing with the relationship: y = h * R + x * v * h where: x = (N - M) * exp(-Q * u) + M which gives the principal equation: y = h * R + v * h * (N - M) * exp(-Q * u) + v * h * M All uppercase letters are constants, and all lowercase letters…
photosynthesis
  • 95
  • 1
  • 11
0
votes
1 answer

R nls() Initial Parameter Problem, nonlinear Regression

I get a error message: Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at initial parameter estimates when using the nls() function like form_Q10_parabolic_SM <- as.formula(Lin_Flux..mymol.m.2.s.1. ~ (rRef<-…
Moe
  • 21
  • 3
0
votes
0 answers

Missing value or infinity using nls in R

I have found similar posts but the solutions did not work for me. I want to fit a curve to some data. I expect the curve to be defined by a function similar to: y = -10*(x-0.3)^2 +1 When I use nls as follows: fit.2<-nls(co2 ~ F * (mvol+G)^k + C,…
dlight
  • 29
  • 3
0
votes
1 answer

R - How to find 1/e in an exponential decay model?

I am working with daily precipitation measurements from nearly 1500 rain gauges. I have calculated the correlation between the measurements of each station and its 20 nearest neighbors. I also have the distances between the stations. I am now trying…
thiagoveloso
  • 2,537
  • 3
  • 28
  • 57
0
votes
0 answers

Multiple non Linear regression

I am trying to predict a job's monthly cost by using the estimated total cost and the duration of the job. I had a raw data with a start date, end date of jobs, their total cost and all costs pertaining to the job and the date those cost were…
0
votes
1 answer

Fitting nls() in r when some x values equal zero

Is it possible to calculate a NLS regression when you have x = 0 ? mydf <- structure(list(x = c(0, 25.8, 51.6, 77.4, 103.2, 129, 154.8, 180.6, 206.4, 232.2, 258), y = c(1, 0.04347826, 0.021739129, …
Josh J
  • 395
  • 1
  • 3
  • 13
0
votes
1 answer

nlsLM maxiter won't change

I'm running a for loop to do bulk nonlinear regression. The problem is, some columns end up causing an error because there aren't enough iterations. Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xy, : number of…
0
votes
0 answers

'singular gradient' error when producing von Bertalanffy growth model using the nls() function

I am trying to produce a von Bertalanffy growth model in R which uses the nls() function, but getting the 'singular gradient' error The dataset 'FladenA' is in reference to the location where my sample is from, and contains 'maximum height' and…
JaneEarland
  • 1
  • 1
  • 2
0
votes
1 answer

Smooth curve of a four parameter polynomial

I'm working with an nls model using this formula (b1 * ((b2 * x)^b4)) / (1 + ((b2 * x)^b4))^(b3 / b4) I use nls2 package with a random algorithm to find the initial values. This my code for the function of formula and curve: eqn <- function(x){(b1 *…
HYDR0GEN
  • 91
  • 1
  • 10
0
votes
1 answer

How to specify data range for nls function in r?

I am sorry for maybe a trivial question, but unfortunately i haven´t found a solution for it. Here is my problem... I have created a function bm6, with 3 unknown parameters (a, l, p), with which i want to aproximate the measured data, that are found…
tu7
  • 5
  • 3
0
votes
0 answers

How can I get lm() and nls() solvers in R to handle linear formulas with offsets self-consistently?

I have some time series data (x, y) which is consistent with a linear model. I would like to construct a regression formula in which one of the coefficients corresponds to the y-value at a specific moment in time (for example, Jan 1, 2013), rather…
stachyra
  • 4,423
  • 4
  • 20
  • 34
0
votes
1 answer

nls sslogis: using a dummy variable as an interaction term to compare two sigmoid models

I use the following model in my code: model <- nls(y ~ SSlogis(x, Asym, xmid, scal), data = data.frame(x, y)) There is a variable (V) with two levels: V1 and V2 Model 1: Fitting Y to X with a sigmoid function when V=V1 --> asymptote1 Model 2:…
Barbaletta
  • 13
  • 3