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

Extract model parameters from nls model for loop

We have this for loop: tenIDs <- unique(ten_squirrel$squirrel_id) tenIDs [1] 5241 3102 2271 3119 3216 #for loop to run through all the squirrels for (i in tenIDs){ #Creating our dataframe for squirrel_id "i" Individual_DFs <- ten_squirrel %>%…
Blundering Ecologist
  • 1,199
  • 2
  • 14
  • 38
0
votes
1 answer

What is no non-missing arguments for `nlsLM` in the context of fitting two parameters?

My goal is to use nlsLM or nls which will optimized the parameters p & U in my formula. However, I am running into algorithm issues, which as shown below, does not seem satisfy nlsLMso it can run. More details are below, but can someone help me…
Toy L
  • 55
  • 6
0
votes
1 answer

Fitting a sine wave model on POSIXt data and plotting using Ggplot2

Long-time reader, first-time asker here :) I have some data collected at specific times and dates, and there is reason to hypothesize the data roughly follows a 24-hour cycle. I would like to fit a sine wave model on my data as a function of time,…
0
votes
1 answer

Diff() incompatable in nlsLM package?

Question: Thank you in advance! does nlsLM not work with diff? I am simply trying to do g*(p[i]-p[i-1])/(x[i]-x[i-1]) and use nlsLM to find the value of fitting parameter g that can fit y I use diff without nlsLM as…
Toy L
  • 55
  • 6
0
votes
1 answer

Multi-peak Gaussian fit in R with small number of sample

I have only five data set to predict two bimodal Gaussian fit like this one. x = c(51,92,220, 280, 333) y = c(40,80,20,60,40) Here's an example of the plot and loess line using ggplot. I want to get an equation through Gaussian curve fitting. So,…
0
votes
2 answers

Linking against WinNLS

What static library should I use to link against to use the NormalizeString() function? In contrast with most functions documented on MSDN, the static library required to use the function is not declared. I tried using the name derived from the…
André Caron
  • 44,541
  • 12
  • 67
  • 125
0
votes
2 answers

nlsList -incorrect usage?

I am trying to run a non-linear regression on a dataset whereby I would like to run a new regression for each group. The data frame is much like this one: Date <- as.POSIXct(c("2021-05-25","2021-05-20",…
0
votes
3 answers

Looping over grouped data using the nls function in R

I have a grouped dataset. I have my data grouped by GaugeID. I have an nls function that I want to loop over each group and provide an output value. library(tidyverse) library(stats) # sample of data (yearly), first column is gauge (grouping…
katsin
  • 23
  • 4
0
votes
0 answers

Fitting function y ~ a*x^b*z^c

I have following dataframe: df <- structure(list(y = c(0.82, 0.77, 0.46, 0.7, 0.82, 0.92, 0.84, 0.88, 0.86, 0.92, 0.91, 0.96, 0.91, 0.92, 0.89, 0.95, 0.95, 0.88, 0.92, 0.88, 0.94, 0.72, 0.9, 0.95, 0.96, 0.92, 0.94, 0.93, 0.93, 0.94, 0.93, 0.89,…
raghav
  • 533
  • 2
  • 11
0
votes
1 answer

find the best curve to fit a family of curves using R

I have a process which generates a set of numbers (< 1) at each run. the process is run till the cumulative sum of the numbers generated equals 1. So each set might have different count of the numbers generated. But the sum total of each set is…
0
votes
1 answer

Non-linear regression, nls, in R: singular gradient

I want to fit my data to a specific function that has already been optimized using Matlab. I get the following error: 'Warning message: Computation failed in stat_smooth(): singular gradient ' Please help! Here is my R code: tibble x y …
David N.F.
  • 35
  • 4
0
votes
0 answers

How to estimate the parameters of a model using NLS (or other) regression?

I am trying to estimate the parameters of a theoretical model using a NLS (non linear least square) regression in Stata.The parameters are: alpha (sensitivity to the assets' returns of participants in our experiment), beta (sensitivity to risk) and…
0
votes
0 answers

Advice for producing confidence intervals around fitted points of a non-linear model in R?

I have been trying for a while to generate confidence intervals around each of my predicted points that my models generate. This is driven by the fact that I create annual estimates by summing estimates for short intervals of time, and to generate…
Cameron
  • 164
  • 14
0
votes
1 answer

R Finding logistic curve with nls

I have a problem with logistic curve in R for panel data which are here: https://docs.google.com/spreadsheets/d/1SO3EzFib7T3XqTz1xZCU2bZFTB0Ddhou/edit?usp=sharing&ouid=110784858039906954607&rtpof=true&sd=true I tried: log <- nls(lrc~SSlogis(time,…
Lovely97
  • 1
  • 1
0
votes
1 answer

Helps plot the graph when the variable has equal values

The code below generates a graph with dots and a "prediction" line, so to speak. In this case, it is generating for dmda=01/07. However, I cannot generate a graph for the day 02/07 or 03/07. From what I understand it is due to the values ​​of the…
Antonio
  • 1,091
  • 7
  • 24