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

Scope of nls selfStart functions

I'm building a package that will: read in a data set determine which components are needed to model the data1 build a self-starting NLS model using those components apply that model to the data The result is stored in a list that contains the…
Tyler
  • 9,872
  • 2
  • 33
  • 57
1
vote
0 answers

Fitting a line to an asymptotic distribution in r

I'm working on a school assignment, where I am supposed to preform a non linear regression on y= 1-(1/(1+beta*X))+U, we generate Y with a given beta value, and then treat X and Y as our observations and try to find the estimate of beta. I've been…
1
vote
2 answers

Multiple inverse.predict() for Gompertz equation

After modelling a series of data to the Gompertz equation, I would like to predict the value on the x axis from the outputted parameters for a given y. However, predict() only predicts the y values for given x's and inverse.predict() only does this…
Ian
  • 47
  • 1
  • 5
1
vote
1 answer

How to fit a two-term exponential in R?

I would like to fit a two-term exponential model to my data given as (x,y), i.e. f(x) = a * exp(b * x) + c * exp(d * x) In essence, I need to replicate Matlab's exp2 model type in R calculated as f = fit(x, y, 'expo')
Mel Z.
  • 21
  • 3
1
vote
1 answer

Constrain nlsLM() with a cost function

I have a dataframe df df<- structure(list(ID = structure(c(1L, 3L, 5L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 31L, 32L, 33L, 36L, 37L, 40L, 41L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 52L, 53L, 54L, 56L,…
SimonB
  • 670
  • 1
  • 10
  • 25
1
vote
1 answer

How does one extract hat values and Cook's Distance from an `nlsLM` model object in R?

I'm using the nlsLM function to fit a nonlinear regression. How does one extract the hat values and Cook's Distance from an nlsLM model object? With objects created using the nls or nlreg functions, I know how to extract the hat values and the…
Karl_R
  • 77
  • 1
  • 5
1
vote
1 answer

R nlsLM / nls fitting quality with low datapoint number

While I was using nlsLM from minpack.lm for a while with great results, I am now facing unexpected trouble in terms of fitting quality with less datapoints supplied. In the example you see one fitting with 750 datapoints and one with around 50.…
Robin K
  • 68
  • 6
1
vote
2 answers

R curve fitting (multiple exponential) with NLS2 and NLS

I have some difficulties getting a specific curve to fit in R, while it works perfectly fine in a commercial curve-fitting program. The formula that the data should fit to is: y(t) = A * exp(-a*(t)) + B * exp(-b*(t)) - (A+B) * exp(-c*(t)) So for…
redtails
  • 11
  • 1
  • 4
1
vote
0 answers

Using Poisson error structure in nonlinear fit

I fitted a trilinear model library(nlstools) library(nlsMicrobio) library(investr) # for plotFit function trilinear LOG10N ~ LOG10N0 - (t >= Sl) * (t <= (Sl + (LOG10N0 - LOG10Nres) * log(10)/kmax)) * kmax * (t - Sl)/log(10) + (t >= Sl) * (t > …
Tom Wenseleers
  • 7,535
  • 7
  • 63
  • 103
1
vote
1 answer

plotting nls fits with overlapping prediction intervals in a single figure

Say I some data, d, and I fit nls models to two subsets of the data. x<- seq(0,4,0.1) y1<- (x*2 / (0.2 + x)) y1<- y1+rnorm(length(y1),0,0.2) y2<- (x*3 / (0.2 + x)) y2<-…
colin
  • 2,606
  • 4
  • 27
  • 57
1
vote
2 answers

Php, Oracle Package and NLS Settings

with this environment: Oracle Database 11g 11.2.0.3.0 64bit Production PHP version: 5.3.3 OCI8 Version 2.0.7 I have a web site in Php language that executes: ALTER SESSION SET NLS_DATE_FORMAT = ''YYYY/MM/DD HH24:MI:SS" when it loads the first…
user1
  • 556
  • 2
  • 6
  • 22
1
vote
2 answers

R - Confidence bands for exponential model (nls) in basic graphics

I'm trying to plot a exponential curve (nls object), and its confidence bands. I could easily did in ggplot following the Ben Bolker reply in this post. But I'd like to plot it in the basic graphics style, (also with the shaped polygon) df <-…
Juanchi
  • 1,147
  • 2
  • 18
  • 36
1
vote
1 answer

How to do fitting for each subsets of data and plot their fitting curves?

Actually I have done much of the thing before I ask here and done lots of search but couldn't find the solution so far. I have a subset of data that I need to fit each subset. On the other hand, when I try to plot regression lines of each of these…
Alexander
  • 4,527
  • 5
  • 51
  • 98
1
vote
1 answer

R: functions generated by a function for nonlinear fit - how to specify a parameters set

What I am trying to do is to make a non-linear regression using possible submodels of my full model and then choose the most apropriate model using AIC criterion. The problem is to generate all possible submodels and then apply them to nls function…
Marta Cz-C
  • 759
  • 1
  • 8
  • 18
1
vote
1 answer

Exponential fitting with R

I have a dataset like this df x y 7.3006667 -0.14383333 -0.8983333 0.02133333 2.7953333 -0.07466667 and I would like to fit an exponential function like y = a*(exp(bx)). This is what I tried and the error I get f <- function(x,a,b) {a *…
user3036416
  • 1,205
  • 2
  • 15
  • 28