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

Error using deltaMethod with nls object in R

I'm trying to use the deltaMethod in the car library, but I'm getting an odd error. library(car) x=c(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11,…
steiny
  • 155
  • 6
4
votes
1 answer

Using predictNLS to create confidence intervals around fitted values in R?

I want to build confidence intervals around a large set of fitted values using predictNLS from the propogate package in R. As an example, I will use the data set they reference in the function description…
Cameron
  • 164
  • 14
4
votes
1 answer

Using an extended-ASCII collation table in C for Win32

In an existing app an API was used to convert all ASCII characters to an uppercased byte, for sorting purposes. cafe == CAFE == Café == CAFÉ. The characters e, é and E all became the character E, in a sorting name. So the value of table[137],…
Xynixme
  • 51
  • 6
4
votes
0 answers

nls() error - convergence failure: singular convergence (7)

I'am trying to estimate a heterogeneous asset pricing model for my thesis in R. However when I run my code I get the error; Error in nls(P ~ PfitHV(P, Y, r, g, Beta, Phi1, Phi2, Delta, W), start = start.val, : Convergence failure: singular…
4
votes
2 answers

Non-linear fitting with nls() is giving me singular gradient matrix at initial parameter estimates. Why?

This is my first attempt at fitting a non-linear model in R, so please bear with me. Problem I am trying to understand why nls() is giving me this error: Error in nlsModel(formula, mf, start, wts): singular gradient matrix at initial parameter…
Ramiro Magno
  • 3,085
  • 15
  • 30
4
votes
1 answer

Resolving minFactor error when using nls in R

I am running nls models in R on several different datasets, using the self-starting Weibull Growth Curve function, e.g. MOD <- nls(Response ~ SSweibull(Time, Asym, Drop, lrc, pwr), data = DATA) With data like this, it works as expected: GOOD.DATA…
EcologyTom
  • 2,344
  • 2
  • 27
  • 38
4
votes
1 answer

How to calculate 95% prediction interval from nls

Borrowing the example data from this question, if I have the following data and I fit the following non linear model to it, how can I calculate the 95% prediction interval for my curve? library(broom) library(tidyverse) x <- seq(0, 4, 0.1) y1 <- (x…
FMM
  • 1,857
  • 1
  • 15
  • 38
4
votes
1 answer

How to use the 'weights' in the nls (non-linear least squares) function in R?

My question is on how to correctly interpret (and use) the 'weights' input variable in the nls function of R for non-linear weighted least squares regression. The solution for solving the unknown parameters in weighted least squares theory is: From…
user121
  • 849
  • 3
  • 21
  • 39
4
votes
3 answers

how to use method="nlsLM" (in packages minpack.lm) in geom_smooth

test <- data.frame(Exp = c(4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), t = c(0, 0.33, 0.67, 1, 1.33, 1.67, 2, 4, 6, 8, 10, 0, 33, 0.67, 1, 1.33, 1.67, 2, 4, 6, 8, 10, 0, 0.33, 0.67, 1, 1.33,…
JD Zhu
  • 49
  • 2
4
votes
1 answer

ggplot: fit a curve (geom_smooth method="nls") with CI95% bands

With data published in this site, about enzyme kinetics: Enz <- c("WT","WT","WT","WT","WT", "WT","WT","WT","WT","WT", "WT","WT","WT", "H297F","H297F","H297F", "H297F","H297F","H297F", "H297F","H297F") S…
Juanchi
  • 1,147
  • 2
  • 18
  • 36
4
votes
1 answer

How to place bounds on nls coefficients?

Is there a way in which to constrain the range of values an NLS coefficient can take on in R? I know the shape of the curve that should exist for my data; however, NLS is failing to produce such a curve by producing a power coefficient of < 1. In…
jbukoski
  • 167
  • 1
  • 13
4
votes
1 answer

do a nonlinear least square fit in r

I have two vectors: y <- c(0.044924, 0.00564, 0.003848, 0.002385, 0.001448, 0.001138, 0.001025, 0.000983, 0.00079, 0.000765, 0.000721, 0.00061, 0.000606, 0.000699, 0.000883, 0.001069, 0.001226, 0.001433, 0.00162, 0.001685, 0.001604, 0.001674,…
4
votes
1 answer

nls singular gradient matrix - fit parameters in integral's upper limits

I am trying to make a nls fit for a little bit complicated expression that includes two integrals with two of the fit parameters in their upper limits. I got the error "Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at…
LauraT
  • 43
  • 2
4
votes
1 answer

Fitting nls to grouped data R

I'm trying to fit a non-linear model to a series of measurements collected on several plots throughout the season. Below is a subsample from the larger dataset. data: dput(nee.example) structure(list(julian = c(159L, 159L, 159L, 159L, 159L,…
4
votes
0 answers

cvFit() cross-validation error for nls model: "Error: object of type 'symbol' is not subsettable"

I have this nls() model running pretty smoothly, and I want to be able to do a cross-validation using the cvTools package, but I get this error when I run the cvFit() function: Error: object of type 'symbol' is not subsettable RStudio…
Chris. Z
  • 365
  • 1
  • 7
  • 17
1 2
3
44 45