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

Modeling a repeated measures logistic growth curve

I have cumulative population totals data for the end of each month for two years (2016, 2017). I would like to combine these two years and treat each months cumulative total as a repeated measure (one for each year) and fit a non linear growth model…
0
votes
1 answer

nls2 with nested functions

I am trying to find parameters using the nls2 package. As the formula I am trying to optimize parameters for is quite complex, I try to use functions that I call within the formula I optimize with the nls2…
Patrick Glettig
  • 541
  • 1
  • 6
  • 12
0
votes
0 answers

Goodness of fit for nonlinear model in R

Is there a sensible parallel to R^2 or similar model fit statistics for nonlinear regression with nls() in R. Is there something implemented in a package? nlstools package does not offer such statistic but plenty of useful diagnnostics etc.
striatum
  • 1,428
  • 3
  • 14
  • 31
0
votes
1 answer

R: nls() error. "singular gradient matrix at initial parameter estimates"

I have a simple example below (which doesn't work) that attempts to do multivariate fit using the default algorithm (Gauss-Newton). I get the error: "Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at initial parameter…
Entropy
  • 133
  • 2
  • 12
0
votes
1 answer

plotFit - data plotted as bars instead of points?

I am using the plotFit function in the investr package in R to display my data as follows: Figure 1 The code I am using to generate this is simply: plotFit(nls model, interval = "confidence", level = 0.95, pch = 19, shade = TRUE, col.conf =…
0
votes
0 answers

predicting values witn non-linear regression

My non-linear model is the following: fhw <- data.frame( time=c(10800, 10810, 10820, 10830, 10840, 10850, 10860, 10870, 10880, 10890), water=c( 105, 103, 103, 104, 107, 109, 112, 113, 113, 112) ) nl <- nls(formula = water ~…
0
votes
0 answers

Extrapolating a fitted curve with predict nls in R

I'm trying to predict a nls fit in R. My values are intensities (y) and excitation energy (x). My code is the following: mydata<-read.delim("TrapDepthExcSpec.txt", header = TRUE) x <- mydata[1:5,1] y <- mydata[1:5,2]…
0
votes
0 answers

Error: nls models, parameters without starting value

I'm finalizing my analysis through R Studio but I keep getting the following error: Error in nls(Lambda ~ (exp(a + (b * AvgTemp) + (c * (AvgTempSQ)))) * ((f + : parameters without starting value in 'data': Lambda, AvgTemp, AvgTempSQ, Avg9mpl2…
0
votes
1 answer

nls poor curve fitting

I'm having trouble fitting several different sigmoidal curves. A little help for a better fitting would be really appreciated. I am trying three different models: 4 parameters nls(y ~ a + (k-a) /(1 + (x/c)^e)^m, start=list(a=a_start, k=k_start,…
Ribas
  • 137
  • 1
  • 11
0
votes
1 answer

fitting with conditional in grouped data

Sorry for too long question but I'll try to be clear as possible about the problem. I am trying to do fitting in different groups in data and trying to get fitting coefficients for each group. I looked around but could not exactly the same problem…
Alexander
  • 4,527
  • 5
  • 51
  • 98
0
votes
2 answers

nls2 treats vectored initial values as single elements, unlike nls

I noticed that I can fit parameter vector, as below, using nls. This let's me decide the number of parameters I want to fit. As in the example below; where I am fitting y = k + a_1 x^2 + a_2 x^3 + a_3 x^3. I can simply change the number of initial…
kangaroo_cliff
  • 6,067
  • 3
  • 29
  • 42
0
votes
1 answer

ORA-01861: literal does not match format string 01861

I have given query for which i am getting error as SQL Error: ORA-01861: literal does not match format string 01861. ORD_DEL_DATE is date data type and the value is stored 27-SEP-2017 12-00-00 in this column. Its not possible for me to change the…
Andrew
  • 3,632
  • 24
  • 64
  • 113
0
votes
1 answer

singular gradient matrix at initial parameter estimates

I am fitting Lotka-Volterra model to some data and my simple code is : LCC<-c(11953.36,27413.50, 54823.75, 90904.73, 119250.34, 137679.14, 137750.79, 141107.43, 146356.56, 179280.00, 213037.07, 286138.03, 373380.14, 483474.16, 561950.42,…
0
votes
1 answer

How to use stats::nls non-linear least squares regression in caret?

I'm comparing a bunch of Machine Learning models on a dataset I have. The current model in production is a equation of the form: y ~ a + b * x1^c * x2^d * x3^e, Since I'd like to use the current situation as a benchmark to asses the improvement I'd…
marqram
  • 725
  • 12
  • 26
0
votes
1 answer

Predict for wider range

I would like to fit the data and predict y values for wider x range. Lets assume I have 'iris' data set and use following data for prediction from this post library(dplyr) cc <- iris %>% group_by(Species) %>% do({ mod <- nlsLM(Sepal.Length…
Alexander
  • 4,527
  • 5
  • 51
  • 98