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

Nonlinear multiple regression in R

I'm trying to run a nonlinear multiple regression in R with a dataset, it has thousands of rows so I'll just put the first few here: Header.1 Header.2 Header.3 Header.4 Header.5 Header.6 Header.7 1 -60 -45 615 720 …
japem
  • 1,037
  • 5
  • 16
  • 30
7
votes
1 answer

Dojo custom build with NLS / localisation

I have a problem implementing a cross domain custom build in Dojo. The situation is as follows: i have a pretty large application, with a good number of localisation bundles, so basicly the directory structures is like core\ (my module) nls\ …
aciobanu
  • 391
  • 1
  • 4
  • 14
6
votes
1 answer

fitting first order equation with nlme and lsoda

I a trying to fit a first order differential model using nlme and lsoda. Here is the basic idea: I first define the function allowing to generate the solution of the differential equation: library(deSolve) ODE1 <- function(time, x, parms)…
denis
  • 5,580
  • 1
  • 13
  • 40
6
votes
1 answer

Fit and compare multiple sigmoid curves in R

I would like to fit multiple curves at once, and compare them statistically, in terms of their 3 estimated parameters – asymptote, slope and x0. Here is an idealized image of the data to be modeled: Most searchable pages turn up methods to fit a…
Matt74
  • 729
  • 4
  • 8
6
votes
1 answer

nls() false convergence (despite good starting values)

I have been working on a curve fitting script which fits 3 exponentially modified Gaussians (EMGs) to a convolved curve. My base function is similar to a Gaussian distribution, but includes a third parameter (the first two being mu and sigma) which…
Ryan
  • 203
  • 2
  • 9
6
votes
1 answer

R : catching errors in `nls`

I'm fitting some exponential data using nls. The code I'm using is: fit <- nls(y ~ expFit(times, A, tau, C), start = c(A=100, tau=-3, C=0)) expFit is defined as expFit <- function(t, A, tau, C) { expFit <- A*(exp(-t/tau))+C } This…
nico
  • 50,859
  • 17
  • 87
  • 112
6
votes
1 answer

nls - Convergence failure: singular convergence (7)

The following nls code throws the following error Convergence failure: singular convergence (7) for fm2(for Data2). But the same code for similar dataset works fine (fm1 for Data1). Works Fine for this Data Set Data1 <- structure(list(D = c(0L, 0L,…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
6
votes
1 answer

Modifying a curve to prevent singular gradient matrix at initial parameter estimates

I want to use y=a^(b^x) to fit the data below, y <- c(1.0385, 1.0195, 1.0176, 1.0100, 1.0090, 1.0079, 1.0068, 1.0099, 1.0038) x <- c(3,4,5,6,7,8,9,10,11) data <- data.frame(x,y) When I use the non-linear least squares procedure, f <-…
Vochmelka
  • 199
  • 1
  • 8
5
votes
2 answers

R_using nlsLM() with constraints

I am using nlsLM {minpack.lm} to find the values of parameters a and b of function myfun which give the best fit for the data set, mydata. mydata=data.frame(x=c(0,5,9,13,17,20),y = c(0,11,20,29,38,45)) myfun=function(a,b,r,t){ …
rm167
  • 1,185
  • 2
  • 10
  • 26
5
votes
1 answer

How to plot non-linear regression lines within groups and total data in ggplot2?

I have a simple data set with two continous variables (Vesicle and Cells), and a single grouping variable with two levels (HC and RA), simulated here: ###Simulate Vesicle variable### Vesicle.hc <- sort(runif(23, 0.98, 5)) #HC group Vesicle1.ra <-…
Hefin
  • 77
  • 1
  • 2
  • 9
5
votes
1 answer

Dojo Build with NLS - requireLocalization(..) fail?

My question, while at first somewhat similar to this one, seems to be a more basic question - and might be signaling a bug in the build system. I've created a custom build for my dojo application. I only build one layer right now, here's what the…
JasonWyatt
  • 5,275
  • 1
  • 31
  • 39
5
votes
2 answers

R how to use bounds and the "port" algorithm in nlslist?

I would like to fit curves on a number of data sets, grouped by treatment. This was working very well with nlslist, but now I would like to introduce upper bounds to my parameters. Introducing bounds does work out very nicely when I fit each group…
5
votes
1 answer

Extract coefficients from ggplot2-created nls fit

There's a nice explanation here of how to use ggplot2 to create a scatterplot, fit the data using nls, and plot the fit, all in one line, like so myhist = data.frame(size = 10:27, counts = c(1L, 3L, 5L, 6L, 9L, 14L, 13L, 23L, 31L, 40L, 42L, 22L,…
Drew Steen
  • 16,045
  • 12
  • 62
  • 90
4
votes
4 answers

How get plot from nls in R?

In R I use nls to do a nonlinear least-squares fit. How then do I plot the model function using the values of the coefficients that the fit provided? (Yes, this is a very naive question from an R relative newbie.)
murray
  • 737
  • 2
  • 10
  • 28
4
votes
1 answer

R Power Fit with nls different from excel

I have a data set (below) with a power relationship. (Y =aX^b) The power fit in Excel and xmgrace gave me an almost identical values for the fit. (R^2 of 0.993) Y = 215.47 X^0.812 However when I try R's nls() function I get a different value. Plus…
lochi
  • 860
  • 2
  • 12
  • 26
1
2
3
44 45