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
2 answers

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

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. dput(head(Mfrq.df.2)) structure(list(User.ID = c("37593", "38643", "49433", "60403", "70923",…
MK25
  • 11
  • 4
0
votes
2 answers

R equivalent of excel exponential trendline (including equation)

The attached picture shows the exponential curve fitting and the exponential equation for this set of data I have. However, I have 219 samples just like the picture that I would like to code in r & get the value for the exponential parameters (the…
MK25
  • 11
  • 4
0
votes
0 answers

nls-Fitting data with Weibull density functions

I am trying to fit my data with a Weibull density functions. eventually, I want to smooth my observations for the entire year so that I can create a smooth GPP (my observation)- DOY (day of the year) curve. The data is detached at the end of my…
JeffAlan
  • 1
  • 1
0
votes
1 answer

Issue with nls model specification in R (singular gradient error)

I am trying to fit a non-linear model using nls in R, however, I can't seem to get the model specification correct. Any advice on how to correct the model, would be much appreciated. A minimal example below. # Import dummy data data <-…
Guy Sutton
  • 45
  • 3
0
votes
1 answer

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 interval, plus during the summary. Warning message:…
Satomi
  • 3
  • 1
0
votes
1 answer

nls.lm - Relative error in the sum of squares is at most `ftol'

I am trying to fit experimental data to a set of 3 PDEs: dX/dt = mumax.(S/(Ks+S)).(1-X/Xm).X dS/dt = -1/Y_x/s * dX/dt - m_s.X - k_LD * dL/dt dL/dt = -kl * L I got error No. 6 of 'ftol': "Error in chol.default(object$hessian) : the leading minor of…
Cuong Dao
  • 5
  • 2
0
votes
0 answers

How to print out the parameters change in nlsLM function in R?

I want to see how the parameters change with the change of MSE. I want to print all the values of the parameters and the MSE associated with it?
ryan
  • 1
  • 1
0
votes
1 answer

Logistic function settings in r

After I made a ggplot of my data I'd like to adjust each curve with a function. I first adjust with nls function, but for the dark blue one, it doesn't work, and it's obvious when we see the curve shape. So I want to make a logistic function…
0
votes
2 answers

plot separate curves for non-linear (nls) model with categorical variable and separate parameter values

I have a dataset of age and length, plus some categorical variables including sex and location (2 level factor). I have fit a Gompertz model to this, using nls(): gompertz <- nls(Length~a*exp(-b*exp(-c*age)), data=df, …
faith
  • 15
  • 4
0
votes
1 answer

nls: Nonlinear Least Squares: model fitting done, now get stuck at finding x (y=0)

I have a series of experimental rT and T. I am using nls to fit my data to this formula: rT~exp(aa * T) - exp(aa * Tmax - (Tmax - T)/deltaT) + bb The nls fitting returned an nls object and gave me the estimated parameters aa, bb, Tmax, deltaT in the…
0
votes
0 answers

Change value for an object in an R environment in a for loop

I am trying to change the value of an object in R environment. The code is given thus. and the error message: myco <- function(form, data, start,tol=1e-06,maxit=10000) { env <- new.env(hash = TRUE, parent = environment(form)) for(i in…
Teniola
  • 3
  • 2
0
votes
1 answer

why am I getting so strange t statistics and p values in the nls() output?

I'm running a nonlinear multiple regression with the nls() function with one dependent variable (Gross Primary Production (GPP)) and three independent variables (solar irradiance (RAD), Green Fractional Cover (GFC) and Volumetric Water Content…
Fra AdV
  • 1
  • 1
  • 3
0
votes
1 answer

How to use nls with caret to do cross-validation

I have fit several models using nls to the same data and am trying to figure out how to use caret to do K-fold cross-validation (eg., here). This SO question asked a general question about using nls in caret for a single model. However, the answer…
D Kincaid
  • 167
  • 1
  • 13
0
votes
0 answers

nls fitting "Missing value or an infinity produced when evaluating the model" or "number of iterations exceeded maximum of 50"

I am an R newbie trying to fit stable conservative tracer-related values to a particular model accepted by experts. The goal is to get an estimated coefficient value of a. Here is the error I keep getting: "Error in numericDeriv(form[[3L]],…
0
votes
1 answer

Coding non linear regression, Exponential decay

Still a novice with R. Background I have the data from Li et al. 2003 paper "Belowground biomass dynamics in the Carbon Budget Model of the Canadian Forest Sector".(https://cdnsciencepub.com/doi/10.1139/x02-165) I am trying to recreate equation 6 in…
James
  • 33
  • 5