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

Plotting with ggplot2 a non linear regression obtained with NLS

I am trying to interpolate with ggplot2 an interpolated function and overlap it to the dotplot graph of the single values. I obtain an error that I am not able to understand, like if I were binding two different vectors of different length. 3:…
GiacomoDB
  • 369
  • 1
  • 10
0
votes
0 answers

Wrong curve plot with a non-linear model with convolution using `fft()` in R

I have a non-linear model ExpDec2RC fitted to the following data. data <- read.table("https://gitlab.com/-/snippets/1999226/raw", sep = "\t") colnames(data) <- c("irf", "decay") data$t <- 1:nrow(data) data <- data[367:1279,] data$t <- data$t -…
Crops
  • 5,024
  • 5
  • 38
  • 65
0
votes
0 answers

Fit data to a logistic function with a known asymptote in R

Example dataset: x <- 1:5 y <- c(0.01,0.02,0.05,0.1,0.2) df <- data.frame(x, y) My goal is to fit this data to a logistic function. I know logistic functions are normally used for binomial data, but in this case my data is continuous. Since the y…
0
votes
0 answers

model makeham using nls with 2 categorical variables

I want to use nls to do a model makeham with 2 categorical variables, with just 1 variable it works. For example, # Create the data df <- data.frame(edad = c(30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,…
bubleskmy
  • 131
  • 1
  • 9
0
votes
0 answers

Confidence Intervals while using nls()

I am writing a code to model the inactivation of bacteria. I was able to get the model using nls(). Now, when I am trying to calculate and plot the confidence and prediction intervals, I am unable to get a proper fit. The lower CI and PI are being…
0
votes
1 answer

nls() : “Error singular gradient matrix at initial parameter estimates ”

I've read many similar questions but still couldn't find the answer. Here is some data that I'm using to calibrate the equation below: set.seed(100) i <- sort(rexp(n = 100,rate = 0.01)) Tr <- sort(runif(n = 100,min = 5,max = 100)) k_start <-…
0
votes
2 answers

loop function with nls

I am struggling with looping nls functions. So here is an example data set for a single sample dat<-read.table(text="time y 1 4.62 2 13.55 3 30.82 6 93.97 12 145.93 24 179.93", header = TRUE) plot(data);lines(data) model <- nls(y ~ Max * (1-exp(-k *…
0
votes
1 answer

How to do an exponential regression model?

I have a small data base (txt file). I want to obtain an exponential regression in R. The commands that I am using are: regression <- read.delim("C:/Users/david/OneDrive/Desktop/regression.txt") View(regression) source('~/.active-rstudio-document',…
Another.Chemist
  • 2,386
  • 3
  • 29
  • 43
0
votes
0 answers

How can I make nls formula with limited start value in R

I made this nls model formula1 <- nls(y ~ a+(x/500)^b, data=my_data, start =list(a=1, b=1)) Then I got the result below, summary(formula) Parameters: Estimate Std. Error t value Pr(>|t|) a -0.5578576 0.2335056 -2.389 0.0251 * b …
YJ Kim
  • 1
  • 1
0
votes
1 answer

How to obtain analysis of variance table for a nonlinear regression model in R

Previously I used SAS to fit data into nonlinear regression model. SAS was able to produce an analysis of variance table for the model. The table displays the degrees of freedom, sums of squares, and mean squares along with the model F test. Please…
SYL
  • 1
  • 1
0
votes
2 answers

How do I calculate doubling time from nls SSlogis logistic growth model

pop.ss <- nls(MRDRSLT ~ SSlogis(TIME, phi1, phi2, phi3), data = testing, na.action = na.omit) theta <- coef(pop.ss) #extracting coefficients plot(MRDRSLT ~ TIME, data = testing, main = "Logistic Growth Model", xlab = "Time", ylab = "MRD")…
Bobby
  • 13
  • 3
0
votes
1 answer

Right syntax for nls() function in R

I am fairly new to R and I am trying to fit a curve using the nls function. I will first generate a curve y using the dgamma function, which I then want to fit using nls. Here is my toy example. ´´´ x <- 1:250 y <- dgamma(x,2,0.02) df <-…
RSale
  • 463
  • 5
  • 14
0
votes
1 answer

Apply penalty function to non-linear least square estimation convergence with bounds in R - package minpack.lm

I want to perform a non-linear least square estimation using the function nlsLM from the package minpack.lm. I want to impose an upper and a lower bound to the estimation to force the algorithm to find the solution within a specific…
shazz
  • 387
  • 1
  • 13
0
votes
1 answer

How to pass loop results as initial parameters for nlslm model?

I am running a nonlinear regression model that needs initial values to start, but the number of variables I want to include may be too large to manually type all the values - therefore I was wondering if there's an alternative to…
GNicoletti
  • 192
  • 2
  • 17
0
votes
4 answers

Connecting to Oracle from Perl

I am trying to connect to Oracle using Perl. I am trying to connect from a Windows XP machine that has Perl installed. I also have downloaded Oracle SQL Developer and Oracle Instant Client. I can connect to the Oracle DB using Oracle SQL Developer…
Gilbert
  • 63
  • 1
  • 2
  • 10