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
1
vote
1 answer

Fit 'nls': singular gradient matrix at initial parameter estimates

I'm new using 'nls' and I'm encountering problems finding the starting parameters. I've read several posts and tried various parameters and formula constructions but I keep getting errors. This is a small example of what I'm doing and I'd very much…
user3262756
  • 649
  • 1
  • 9
  • 27
1
vote
2 answers

How can I write a formula within a loop when the number of variables changes?

I use the following code to fit different exponential curves for each group of observations, and it works just fine. p = c(10,20,15,25,20,30,25,35,30,40,25,35,20,30,15,25,10,20) v =…
1
vote
1 answer

R: epidemic diffusion model using two-dimensional non-linear least squares (nls)

I'm trying to implement an epidemic diffusion model in R. The formula for the diffusion is delta_y=(a+b * y) * (N-y). y describes the current users in period t, N describes the number of potential users, delta_y describes the new users in t and a as…
Lukas Stäcker
  • 319
  • 3
  • 10
1
vote
0 answers

Statistical significance of a nls model in R

I have some multiple linear models without intercept like below: Y = a*X1 + b*X2 + c*X3 However this model is a linear model, but since it does not have an intercept we have to write it as a non-linear model in R: model1= nls(Y ~ a*X1+b*X2, data =…
1
vote
1 answer

Model fitting with nls.lm in R, "Error: unused argument"

I'm trying to use the nls.lm function in the minpack.lm to fit a non-linear model to some data from a psychophysics experiment. I've had a search around and can't find a lot of information about the package so have essentially copied the format of…
ash_sak
  • 11
  • 1
  • 3
1
vote
1 answer

Error supplying appropriate start parameters to nlsLM

I was playing around with the nlsLM function, from the minpack.lm library, and encountered some behaviour that I don't understand. Given that the following function produces output when I supply a numeric vector 'b' as input I wanted to use this…
frank2165
  • 114
  • 2
  • 7
1
vote
1 answer

graphing confidence intervals nls r

I'm in the process of putting some incidence data together for a proposal. I know that the data takes on a sigmoid shape overall so I fit it using NLS in R. I was trying to get some confidence intervals to plot as well so I used bootstrapping for…
MJH
  • 398
  • 2
  • 14
1
vote
1 answer

wrapnls: Error: singular gradient matrix at initial parameter estimates

I have created a loop to fit a non-linear model to six data points by participants (each participant has 6 data points). The first model is a one parameter model. Here is the code for that model that works great. The time variable is defined. The…
1
vote
1 answer

Add a constraint to a nonlinear model in R

I'm having trouble adding a constraint to my nonlinear model. Suppose I have the following data that is roughly an integrated Gaussian: x = 1:100 y = pnorm(x, mean = 50, sd = 15) + rnorm(length(x), mean = 0, sd = 0.03) model <- nls(y ~ pnorm(x, mean…
Gabe
  • 1,722
  • 1
  • 11
  • 7
1
vote
1 answer

not avoiding/skipping errors with try and tryCatch

I have a nlsLM inside a for loop because I want to try different start values to fit my data. I already know that some start values generates this error: singular gradient matrix at initial parameter estimates, but I want to skip this error and…
José Ricardo
  • 301
  • 1
  • 2
  • 7
1
vote
0 answers

dojo nls files - parentheses around root value

I have noticed that in dojo source code there are two ways people are creating their nls files. It's about the use of parentheses. https://github.com/dojo/dojo/blob/master/nls/colors.js: define({ root: ({ aliceblue: "alice blue", …
Michal Fotyga
  • 91
  • 1
  • 4
1
vote
0 answers

Cooks distance for NLS Regression with R

I had to rebuilt my standart lm regression into a nls regression as I had to determine a lower bound for one of my variables: NONLinear <- nls (PD04_AL ~ a * Health_Care + b * Utilities + c * TALOG + d * CFOP + e * GROSS_MARGIN + f *…
WhopWhop
  • 11
  • 2
1
vote
1 answer

nls and log scale in ggplot2

I'm trying to plot 3 non-linear models in ggplot2. It's working in automatic scale but not in log10 scale where I get the "singular gradient error". What could be the problem(s)? The data I'm trying to fit (df1): x y 4.17 0.55 10.08 …
user2165907
  • 1,401
  • 3
  • 13
  • 28
1
vote
1 answer

Vectorising building multiple models in R

I have data (a list with multiple matrix objects) that looks like this: $matrix_1 26/03/2012 02/04/2012 09/04/2012 16/04/2012 23/04/2012 30/04/2012 07/05/2012 14/05/2012 21/05/2012 28/05/2012 26/03/2012 500 40 30 20 21 18 8 7 …
shecode
  • 1,716
  • 6
  • 32
  • 50
1
vote
1 answer

R nls gaussian fit "singular gradient matrix at initial parameter estimates"

I tried to fit my data with a gaussian curve using nls. Because that didn't work, i tried to make an easy example to see what goes wrong: >x=seq(-4,4,0.1) >y=2*dnorm(x-0.4,2)+runif( length(x) , min = -0.01, max = 0.01) >df=data.frame(x,y) >m <-…