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

Non Linear Regression Troubleshooting

Following is an excerpt from my data set: relative frequency and size. As you can see from the open-circles, this is a Gaussian distribution. I am using the nls package in R to fit a nonlinear curve. My equation is or in plain text: c * e^(-(x -…
mindhabits
  • 421
  • 1
  • 3
  • 10
1
vote
1 answer

How to fit a nls model with mixed effects

I want to fit a linear-plateau model with random effects. I found a way to fit the function with nls(), but I don't know how to include random effects. Here is what i have so far: #create…
1
vote
0 answers

Why do i keep having this error message : Warning, Matrix is close to singular or badly scaled. Results may be inaccurate

I am trying to recreate the work in the paper : Artificial-Neural-Network-Based Phase-Locking Scheme for Active Power Filters by Mohammad M. K. Qasim & al. In Section 2 : FREQUENCY ESTIMATION USING NLS, He state : Then He say : since A is not…
KADEM Mohammed
  • 1,650
  • 2
  • 23
  • 45
1
vote
1 answer

Fit a Weibull cumulative distribution to mass passing data in R

I have some particle size mass-passing cumulative data for crushed rock material to which I would like to fit a Weibull distribution using R. I have managed to do this in Excel using WEIBULL.DIST() function using the cumulative switch set to…
Markm0705
  • 1,340
  • 1
  • 13
  • 31
1
vote
1 answer

filter functions keeps failing with missing data argument

I am working on Marketing Mix Modeling and I am following the article https://analyticsartist.wordpress.com/2014/01/31/adstock-rate-deriving-with-analytical-methods/ The article defines the adstock function as below : adstock <- function(x,…
Analytics_TM
  • 493
  • 6
  • 28
1
vote
1 answer

nls failing on some subsets of data, but not on other, similar, subsets

I'm trying to apply an nls function to data by year, so there will be a separate nls function for each year. All the years are broadly similar (exponential decay), but some years the nls() function fails with a "singular gradient" error. data that…
C. Denney
  • 577
  • 4
  • 16
1
vote
1 answer

Joint estimation of parameters from two NLS-regressions

First of all, I am new to the board so excuse me if I am not writing this post in the most optimal way. That aside, I am trying to run some models on optimal entry timing for successive product/service generations. The models are defined as…
1
vote
1 answer

rpy2 problems, nls passing list() as argument from python to R

I am trying to fit a nonlinear curve using rpy2 from numpy array, but are stuck as I do not know how to pass the 'start' argument on the R side. I use R 2.12.1 and python 2.6.6 Error in function (formula, data = parent.frame(), start, control =…
1
vote
0 answers

Error in R nlsModel: singular gradient matric at initial parameter estimates

I want to do a nonlinear regression with nls() in R, but I always get the following error code: Warning: Error in nlsModel: singular gradient matric at initial parameter estimates My nls() function looks like this: nlr <- nls(formula = valuerange1 ~…
DesertFox
  • 11
  • 1
1
vote
1 answer

How to integrate (AUC) nls model and Monte-Carlo confidence interval in R

I'm trying to integrate (resolve the area under) a non-linear function (from nls()) from x= 0 to infinity in R. However, R's integrate function calls for a function (f). In short, I'd like to do something approximating: integrate(my.nls, lower = 0L,…
1
vote
0 answers

'Method Args' for plotting 'nls' regression line with geom_smooth()-- Not working

I am trying to overlay an nls object regression curve on a scatter plot in ggplot2, but I keep running into an error after various attempts in formatting the arguments. I have tried the following recommendation from here, but it does not work…
J.Reising
  • 11
  • 2
1
vote
1 answer

r ADBUG model nls singular gradient

I've tried to fit the following into a ADBUG model using the nls function in r, but the singular matrix error kept repeating and I don't really know how to proceed on doing this... nprice nlv2 [1,] 0.6666667 1.91666667 [2,] 0.7500000…
Joseph
  • 11
  • 1
1
vote
1 answer

nls() in R: Missing value or an infinity produced when evaluating the model

I'm trying to use nls(), but the error in the question was made. Following is the sample data set resembles the original one: rh1 = rnorm(301, 0.75, 0.1) rh1[rh1 > 1] = 1 ta1 = rnorm(301, 302, 3) y1 = rnorm(301, 0.2, 0.05) df_test = data.frame(rh1…
hlee
  • 195
  • 2
  • 12
1
vote
0 answers

R nonlinear regression of cumulative X and Y data

I'm trying to figure how to make a nonlinear regression of some cumulative data of X and Y values. The dataset is based on cumulative items and their respective cumulated demand. I have a plot that looks like this based on the following…
1
vote
1 answer

Starting values for 4 parameter NLS - Chapman Richards function

*Note - I have read several of the posts on how to find starting values for NLS - however, I have not found one with an equation of this form (i.e. 4 parameters, exponent raised to a power) I am struggling tremendously to find suitable starting…