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

Write a program to minimize the sum of squares of recursive exponential function

This is the function that I'd like to code in R, i = 1,2,3,....j-1 a,b,c,f,g are to be determined from nls (with starting value arbitrarily set to 7,30,15,1,2) S and Y are in the dataset The function can be presented in a more computational…
mct
  • 17
  • 3
0
votes
1 answer

Non-linear least squares with arbitrary number of fitting parameters in R

I want to fit a model which includes a sum over a variable number of coefficients, such as here Model I would like to write the code so that the number of coefficients can be specified by a potential user when running the fitting routine (i.e.…
David
  • 9
  • 3
0
votes
2 answers

achieved convergence tolerance (and other outputs) from nls

So, I am using nls() to do nonlinear regression in R. I now have some code which does it for me and I get the correct output (phew!). I can easily store the coefficients in a data frame using <- coeff(), but I also need to store some of the other…
Psychologeek
  • 641
  • 1
  • 5
  • 8
0
votes
1 answer

nesting dataframe references in lm vs nls functions

Say I have some data, as a data frame: GSM<- c(NA, 0.11, 0.12, 0.05, 0.06, 0.43, 0.44, 0.32, 0.29, 0.22, 0.24) enz<- c(18.73287, 48.92596, 51.78783, 12.07112, 17.98551,NA,NA, 62.74149, 25.92524, 17.25657, 32.10908) dat<-data.frame(GSM,enz) I then…
colin
  • 2,606
  • 4
  • 27
  • 57
0
votes
1 answer

Implementation of Stata's "nl" package (nonlinear least squares) in Python

Does anybody know if there is an implementation of the Stata nl (nonlinear least squares) package in Python? I tried to use lmfit as well as optimize.leastsq from scipy, but both do not seem to work. The equation for the regression is Y = x1 + b1 +…
0
votes
4 answers

Error when fitting nls

I always get the error: Error in levels(x) : argument "object" is missing, with no default when trying to fit: fit60 <- nls(Predicted.Bromide~c+a*(1-exp(-b*n)),start=C(a=10,b=0.02,c=0),data=min60) Or with the columns extracted to x=min60min and…
ToTo
  • 1
  • 2
0
votes
2 answers

"Missing value or an infinity produced when evaluating the model"

I'm trying to solve a two-component decay model in R using the nls function, but running into errors. The equation is: Where t is time, Ctot is C1+C2, and p1 and p2 are known proportions of Ctot. my data (dd) is: > head(dd,n=15) t …
squishy
  • 489
  • 1
  • 6
  • 19
0
votes
0 answers

object of type 'closure' is not subsettable, nls function

I just started learning R a few hours ago and I'm trying to do a nonlinear regression to find values for the B coefficients of the formula I created. I want to use position and varResis values to find estimatedOi values, as close as possible of…
0
votes
0 answers

Function in R for trilateration

This is a similar to question to Trilateration for n points and the enquirer has posted the answer since there were no answers. From the parent post, the code is shown for Mathematica and has two variables (X,Y) in output. I am having a difficulty…
KarthikS
  • 883
  • 1
  • 11
  • 17
0
votes
1 answer

How can I use S-curve(sigmoid) in mutivariate nonlinear regression in R?

I am working on Market Mix Modeling - I need to capture impact of different marketing variables on sales of a product through s-curve. Below is the equation I need to use - sales = 1/[1+exp((a1-TV)/a2)] * 1/[1+exp((b1-Radio)/b2)] *…
0
votes
0 answers

using nlsLM() and < length of 'dimnames' not equal to array extent> error

The measurment points (y_i, t_i) are given (whereas in this minimal example the y_i is only 3-dim vector (originally from R^6) and t_i fixed time point. I had to (Not sure if the code, the way it is right now, expresses it) to apply the…
Jelena
  • 1
  • 1
0
votes
1 answer

nlstools - nlsBoot not working

I'm trying to use nlsBoot function from the nlstools package by applying it to a function I created. I get an error when using nlsBoot from the output of my function. However, if I use directly the nls function with the data it works. What is…
user3498523
  • 370
  • 4
  • 10
0
votes
1 answer

How to Use nlsLM function together with one of the apply family function in R

I need a guide about how to do multiple regression columnwise. I have a data frame where I want to get each columns fitting coefficients separately. So far I can have those results for only one column. What I tried so far Maybe assigning the…
Alexander
  • 4,527
  • 5
  • 51
  • 98
0
votes
1 answer

Why is gradient of first iteration step singular in nls with biv.norm

I am trying to fit a non-linear regression model where the mean-function is the bivariate normal distribution. The parameter to specify is the correlation rho. The problem: "gradient of first iteration step is singular". Why? I have here a little…
Gittetier
  • 3
  • 3
0
votes
0 answers

Conditional nls fitting with dplyr+broom

I am using the dplyr and broom combination and try to fitting regression models depending on the condition inside of the data groups. Finally I want to extract the regression coefficients by each group. So far I'm getting the same fitting results…
Alexander
  • 4,527
  • 5
  • 51
  • 98