Skip to main content

Questions tagged [nls]

`nls` is an R routine to fit nonlinear regression models of the form $y = f(x B) + e$. Use this tag for any on-topic question that (a) involves `nls` either as a critical part of the question or expected answer, & (b) is not just about how to use nls or R.

Filter by
Sorted by
Tagged with
0 votes
3 answers
57 views

What is a good starting model for fitting a rotated sigmoidal curve?

I'm trying to make a model to fit a rotated sigmoidal curve in R but don't know where to start when looking for an appropriate equation for the model. Some example data and the type of fit I'm getting ...
jaysmith's user avatar
1 vote
1 answer
76 views

Non-linear regression with very noisy data with nls() in R

I am trying to fit noisy data to a specific model with two parameters which I would like to estimate. Unfortunately, the model fit is just terrible with added noise. Is there anything I can do to ...
leze's user avatar
  • 11
2 votes
1 answer
55 views

Build a logistic model that fits two curves in R

The relation between my dependent variable y and my independent variable x can be described by a logistic regression like: ...
unknown's user avatar
  • 95
0 votes
0 answers
30 views

Statistical significance between sigmoidal regression curves

I have a data-set of weight ~ temperature that was measured in 3 species (A-B-C), each consisting of 2 genotypes (a-b) that were grown in 3 soils (1-2-3) each. Weight ~ temperature for each Soil x ...
unknown's user avatar
  • 95
0 votes
0 answers
65 views

Error in nls model: singular gradient matrix at initial parameter estimates. Cannot figure out appropriate start values [closed]

I'm trying to implement equation 3 from this article research paper, for ease here's a screenshot of the equation: Here's my code for it ...
Favour Onyido's user avatar
0 votes
0 answers
130 views

Normalization of log-returns or normalization of cumulative log-returns

This questions seeks for discussion to find theoretical support for normalizing cumulative log-returns vs normalizing log-returns By "normalizing" (also known as standarizing) I mean it in ...
Alfonso's user avatar
  • 21
0 votes
0 answers
26 views

Can I adjust lambda by 1 or 2 S.E. in exponential decay to potential improvements in retention

(Similar example data to a post I made posted yesterday but a completely different question) I have an exponential decay with off-set function that looks like this: ...
Doug Fir's user avatar
  • 1,588
0 votes
0 answers
39 views

Calculate non linear regression (nls()) prediction interval without a library

I wouldlike to know how to calculate a prediction interval manually, without using a library. Ultimate goal is to write some formula in a spreadsheet based on the model params that would let me ...
Doug Fir's user avatar
  • 1,588
1 vote
0 answers
102 views

Singular gradient errors in nls in R studio [closed]

I make fisheries work, and I need to estimate some parameters from the von Bertalanffy equation: Lt=Linf*(1-exp-K(t-t0)) here Linf, K, and t0 are the parameters that I want to estimate by FSA package ...
Dr Mohamed Ibrahim's user avatar
1 vote
0 answers
55 views

How to weigh residuals based on x-interval in the nls() function in R?

A plot of my data and fit: ...
PMouton's user avatar
  • 11
1 vote
1 answer
106 views

fitting growth curves with nls singular gradient error [duplicate]

I'm having trouble fitting my model to a bacteria growth curve. I made a sample of my data below. Code: ...
KJack718's user avatar
0 votes
0 answers
75 views

Significance of the p-values of the parameters in a non-linear model (using R)

I applied a logistic regression using the nlmrt package to describe the relationship between biomass and the distance and site variables. I got this result, but I ...
Florian B.'s user avatar
0 votes
0 answers
26 views

Issue with understanding the role of a linear regression alongside a non-linear regression

I am working on the movement of fish from the centre of a protected area to a non-protected area. Based on the article by R. Abesamis, I applied to my dataset a logistic decay $D = 1/(1+\exp(S\cdot (I-...
Florian B.'s user avatar
12 votes
3 answers
2k views

nls() singular gradient matrix at initial parameter estimates error

I am trying to run a nls() to interpolate height growth of a tree given a series of samples, where each sample has a value of age, and height. I am using the Richards (1959) method: $$ \textrm{Height}=...
hawkingRadiation_'s user avatar
3 votes
3 answers
789 views

How to get standards errors of the parameters of a non-linear model (R and Excel)

I am working on the movement of fish species from the centre of a protected area to a non-protected area. Based on the article by R. Abesamis, itself inspired by the work of B. Kaunda-Arar (page 91), ...
Florian B.'s user avatar
2 votes
2 answers
338 views

starting values for nls() to solve singular gradient error in R [duplicate]

I am attempting to fit nls() for 520 users to achieve the coefficients of the exponential fitting. The following is a small representation of my data. ...
MK25's user avatar
  • 31
1 vote
2 answers
110 views

Problem choosing an equation for a NLS model I need to present academically

I want to be able to predict the optical density of a radiograph (x-ray image) based on the input factors of depth, SID, KVP, MAS. I'm a lot more familiar with linear models and have never had to give ...
Kerry Brown's user avatar
0 votes
0 answers
90 views

ED50 in non linear logistic regression in R

I am new to R and I want to find the ED50 with its confidence interval in the drc package in R. I found the best model is lorentz.4 according to AIC. But I get a warning message for the confidence ...
satomi's user avatar
  • 1
0 votes
0 answers
22 views

Advice on fitting curve to three-pooled plant decomposition model in r

I have just finished running a plant decomposition experiment measuring the decomposition of pine needles across climate and lithological types. We have mass loss, plant chemistry data (c, n, labile ...
Daniel Fishburn's user avatar
0 votes
1 answer
117 views

Fitting a cubic-like curve to data in R

I tried using nls() in R to fit the following expression to a set of data: where g=9.8, alpha & B_0 are unknown, a = 0.01, z_0 = 0.3 such that: theory <- as.formula(V~-(9.8)ab*(pi)(0.02^2)(T)(...
SomberTheScrub's user avatar
2 votes
0 answers
31 views

Seeking a combination of nls() params that would make this fit curve slightly more acute?

I have some data with fields GrowthRate and DAY. GrowthRate. E.g. If amount is 100 on day 1 and then 110 on day2, GrowthRate is 1.1. Data look like this: ...
Doug Fir's user avatar
  • 1,588
0 votes
1 answer
272 views

Modelling poisson distribution with nls() in R?

I'm trying to model the probability that somebody can do a 90 day Snapchat streak. I have some binary success data in the form of count data (the participant only reached 90 days once): I've ...
Piethon's user avatar
  • 111
0 votes
0 answers
58 views

nonlinear least square optimization for Logistic Regression

Generally I have trained a logistic regression model with: ...
Christian's user avatar
  • 113
4 votes
1 answer
305 views

Correct GLM or NLS to model exponential model with response variable with positive and negative values

I have been struggling to find the right way to model this dataset, this is a Data Frame with the dataset: ...
Derek Corcoran's user avatar
0 votes
0 answers
54 views

R - problem with fitting to a custom non-linear equation

I have a problem. In GraphPad Prism, fitting to the following equation my data produce pretty nice results. However, when I try to repeat in R, it generates terrible output. Here is the code: ...
Maciej Basczok's user avatar
1 vote
1 answer
528 views

Fit exponential decay upwards model - start values give 'convergence failure'

I have some data that when plotted looks similar to this: Then eyeballing the charts on this page, it looks like I might have an exponential decay (Increasing form) relationship? I searched for how ...
Doug Fir's user avatar
  • 1,588
0 votes
1 answer
201 views

Parametric nonlinear term in mgcv

The R library mgcv can handle both parametric linear and non-parametric non-linear terms, but is there any way to let it handle parametric non-linear terms? For ...
S. Robinson's user avatar
0 votes
1 answer
526 views

How to run a nls for multiple dependent variables?

I am unfamiliar with nls however after doing some research on the function it seems to be appropriate for my current analysis. I am testing population declines over ...
Stackbeans's user avatar
1 vote
0 answers
206 views

Sum of two gaussian curves

I have a set of raw chromatographic data (x,y) where I'm trying to evaluate the area of two unresolved peaks separately using gaussian approximations in R. I found this answer from a few years ago (...
laytox's user avatar
  • 11
1 vote
0 answers
652 views

Quantile regression with an exponential function

The following equation: y = a*x**b where y is a nonlinear function of x. By taking logs, the equation can be expressed as: ln(y) = ln(a) + bln(x). I would like to run a quantile regression instead of ...
user3527227's user avatar
0 votes
1 answer
138 views

How can I transfer the exponential relationship to linear?

The exponential relationship between y and x I got is model_1 <- nls(y ~ I(a * exp(-b * x)), start = list(a = 1, b = 0), trace = TRUE) ...
lovemeat's user avatar
1 vote
1 answer
202 views

How to calculate time of day of the peak of a harmonic function fit from phase offset estimate from R nls

I'm trying to calculate the time of day of a harmonic function peak using nls() in R. I've looked at the posts here, here and here, but have not found a method to calculate time of day from phase ...
user3195832's user avatar
0 votes
0 answers
131 views

Why SSgompertz does not work on similar data sets?

I have data that follows a sigmodial shape and the Gompertz function seem to make sense. I wanted to use SSgompertz in nls to find the parameters, but I get sometimes errors. So, I wanted to learn ...
carlos_ArT's user avatar
0 votes
1 answer
285 views

Fitting a non-linear least squares regression to estimate coefficients of parameters in R

I need to fit a non-linear least squares regression to estimate coefficients which are governed by an equation that have parameters obtained from generating data series. Data: ...
Outlier's user avatar
  • 123
0 votes
1 answer
143 views

Is a Google Sheets fit model a valid place to retrieve starting parameters for nls() in R Studio?

0 I am trying to fit an exponential model of form y = ae^(xb) in R to the data I have ran below, using the nls() function. I have read here and in other places that I need to feed the model reasonable ...
Cameron's user avatar
  • 101
3 votes
1 answer
940 views

How to fit a piecewise assembly of nonlinear functions?

I am trying to model vegetation spectral signatures (grey lines) using a two-part piecewise function (black dotted lines). In it, I am trying to use only a few points (red dots) to fit a linear (first ...
Gustavo's user avatar
  • 51
1 vote
0 answers
461 views

using nls in R to fit a distribution to a model - constant error on multiple parameter estimate

I have a distribution of data (x), which I need to fit with a two-species, or three-species model (essentially the sum of two gamma distributions) to find D (the diffusion coefficient). A single-...
SJH1990's user avatar
  • 11
1 vote
1 answer
331 views

NLS analysis in R with timeseries data to remove known effect

I have a timeseries dataset collected by sensors. The data is crack displacement (disp) and temperature (temp). Thermal ...
Eric Krantz's user avatar
1 vote
1 answer
52 views

fitting specific formula/model in r - model possibly not identifiable

I would like to fit the following formula in R: y ~ alpha *(x1_0 * x2_0 * beta_0 + x1_1 * x2_1 * beta_1) Here: alpha, ...
cs0815's user avatar
  • 2,245
6 votes
2 answers
1k views

Interpreting and troubleshooting nls in R with quadratic plateau model

I am trying to run a quadratic plateau model on some proportion data where values are bound between 0 and 100. I would like some help troubleshooting some errors I have encountered, and correctly ...
mb5572's user avatar
  • 123
0 votes
0 answers
1k views

Starting values for an nls model in R [duplicate]

I'm trying to fit an exponential model using nls, but I don't know how to select the starting values for the parameters. I know this question has been answered multiple times, but I spent some days ...
jbarba's user avatar
  • 1
1 vote
1 answer
263 views

Sine curve fit and model tunning using nls in R

I acquired data (motor adaptation =y in function of delays =t ) which I expect to look like a sine wave. I am trying (1) to fit a sine curve in my data and (2)to estimate the best model/parameters. I ...
SophieB's user avatar
  • 11
0 votes
0 answers
2k views

Sine curve fit using nls in R

I acquired data (motor adaptation $y$ as a function of delays $t$ ) which I expect to look like a sine wave. I am trying (1) to fit a sine curve in my data and (2) to estimate the best model/...
SophieB's user avatar
  • 11
0 votes
0 answers
19 views

Sine curve fit using lm, nls and nls2 in R [closed]

I acquired data (motor adaptation =y in function of delays =t ) which I expect to look like a sine wave. I am trying (1) to fit a sine curve in my data and (2)to estimate the best model/parameters. I ...
SophieB's user avatar
  • 11
0 votes
1 answer
1k views

Comparing time series data between three treatment groups (in R)

I have time series data where the response is decreasing over time. The rate of the decrease is supposed to depend on the treatment (the concentration of a drug). By looking at the data I am not sure ...
BForsyth's user avatar
1 vote
0 answers
44 views

r - Understand goodness of a fitted curve [duplicate]

I had to find the equation of curve that represent my data. After trying different function, I got a models that seems fitting my data, at least by plotting them. But this is it. I have no idea how to ...
m_rub's user avatar
  • 31
0 votes
1 answer
3k views

Understand differences between gnls and nls - step halving factor reduced below minimum in NLS step

...
Nicso's user avatar
  • 31
2 votes
1 answer
908 views

Constraining parameters in NLS in R to be less than a value, or greater than a different value

The nls function in R comes with upper and lower arguments to specify the upper or lower ...
CodeGuy's user avatar
  • 473
0 votes
0 answers
65 views

Nonlinear fit in R only works with tightly restricting parameter bounds [duplicate]

I have a reproducible example here with an attempt to use nls to fit a nonlinear function: y = ax/(b+x) + c Even when I set the starting values to be a good, ...
CodeGuy's user avatar
  • 473
0 votes
1 answer
3k views

Singular gradient erros, NLS in R

I'm trying to fit nls(Mound~ a*kg.bag.collar^b + c, start = list(a = 83, b = -.5, c=100), data=test) using the dataset here. I've fit it without trouble without the ...
ecologist1234's user avatar