similar to: nls: example code throws error

Displaying 20 results from an estimated 1000 matches similar to: "nls: example code throws error"

2010 Apr 19
3
nls for piecewise linear regression not converging to least square
Hi R experts, I'm trying to use nls() for a piecewise linear regression with the first slope constrained to 0. There are 10 data points and when it does converge the second slope is almost always over estimated for some reason. I have many sets of these 10-point datasets that I need to do. The following segment of code is an example, and sorry for the overly precise numbers, they are just
2010 Apr 19
2
nls minimum factor error
Hi, I have a small dataset that I'm fitting a segmented regression using nls on. I get a step below minimum factor error, which I presume is because residual sum of square is still "not small enough" when steps in the parameter space is already below specified/default value. However, when I look at the trace, the convergence seems to have been reached. I initially thought I might
2013 Apr 05
1
white heteroskedasticity standard errors NLS
Hello Is there any function to calculate White's standard errors in R in an NLS regression. The sandwich and car package do it but they need an lm object to calculate the error's. Does anyone have idea how to do it for an NLS object ? Regards The woods are lovely, dark and deep But I have promises to keep And miles before I go to sleep And miles before I go to sleep ----- [[alternative
2011 Jun 12
1
Error in NLS example in the documentation
Hello there, I am trying to use R function NLS to analyze my data and one of the examples in the documentation is - ## the nls() internal cheap guess for starting values can be sufficient: x <- -(1:100)/10 y <- 100 + 10 * exp(x / 2) + rnorm(x)/10 nlmod <- nls(y ~ Const + A * exp(B * x), trace=TRUE) plot(x,y, main = "nls(*), data, true function and fit, n=100") curve(100 +
2009 Oct 17
1
custom selfStart model works with getInitial but not nls
Hello, I'm having problems creating and using a selfStart model with nlme. Briefly, I've defined the model, a selfStart object, and then combined them to make a selfStart.default model. If I apply getInitial to the selfStart model, I get results. However, if I try usint it with nls or nlsList, these routines complain about a lack of initial conditions. If someone could point out
2007 Sep 29
1
[Help] Error when using nls
Hi, I am a student of Earthquake Engineering, and am new to R. Currently I try to run nonlinear regression analysis by R. My data has three variables: X, Y, and Z. Z is a function of (X, Y). My R script is as below. rm(list=ls()) # read in data Alldata <- read.table("~/Documents/R/Wu_data.dat", header=TRUE) # assign variables Z <- Wu[[1]] # N1,60 X <- Wu[[2]]
2007 Feb 13
1
nls: "missing value or an infinity" (Error in numericDeriv) and "singular gradient matrix"Error in nlsModel
Hi, I am a non-expert user of R. I am essaying the fit of two different functions to my data, but I receive two different error messages. I suppose I have two different problems here... But, of which nature? In the first instance I did try with some different starting values for the parameters, but without success. If anyone could suggest a sensible way to proceed to solve these I would be
2009 Sep 21
1
How to use nls when [selfStart] function returns NA or Inf??
Hi Everyone, I posted this a couple of weeks ago with no responses. My interface (via gmane) seemed a bit flakey at the time, so I'm venturing to repost with some additional information. I'm trying to write selfStart non-linear models for use with nls. In these models some combinations of parameter values are illegal; the function value is undefined. That's OK when calling the
2012 Feb 13
3
fit data to y~A+B*sin(C*x)
I want to fit discrete data that was measured on a wavegenerator. In this minimal example i generate some artificial data: testsin <- 2+ 5 * sin(1:100) #generate sin data testsin <- testsin+ rnorm(length(testsin), sd = 0.01) #add noise mydata <- list(X=1:100, Y=testsin) # generate mydata object nlmod <- nls(X ~ A+B*sin(C* Y), data=mydata, start=list(A=2, B=4, C=1), trace=TRUE) #
2001 Apr 29
1
Self-starting nls functions
Hello, I am doing several self-starting growth functions for using with nls(). When I list the self-starting functions included in nls library, for instance, SSlogis, there is: > SSlogis function (input, Asym, xmid, scal) ... <environment: 03476D20> attr(,"class") [1] "selfStart" What is this <environment: 03476D20> instruction? By using deriv() and then
2013 Oct 20
5
nlminb() - how do I constrain the parameter vector properly?
Greets, I'm trying to use nlminb() to estimate the parameters of a bivariate normal sample and during one of the iterations it passes a parameter vector to the likelihood function resulting in an invalid covariance matrix that causes dmvnorm() to throw an error. Thus, it seems I need to somehow communicate to nlminb() that the final three parameters in my parameter vector are used to
2010 Mar 13
1
testing parallelism of does-response curves using nls()
Hi, I am trying to use F test or Chi-square test to test if 2 5-parameter (A, B, xmid, scal and H) logistic curves are parallel based on residual sum of squares. What's usually done is to first fit the 2 curves using a constraint (or global) model where all parameters are kept the same except for "xmid"; then fit 2 independent curves using unconstraint models where all 5 parameters
2004 Jul 16
1
Does AIC() applied to a nls() object use the correct number of estimated parameters?
I'm wondering whether AIC scores extracted from nls() objects using AIC() are based on the correct number of estimated parameters. Using the example under nls() documentation: > data( DNase ) > DNase1 <- DNase[ DNase$Run == 1, ] > ## using a selfStart model > fm1DNase1 <- nls( density ~ SSlogis( log(conc), Asym, xmid, scal ), DNase1 ) Using AIC() function: >
2008 Aug 29
1
nls() fails on a simple exponential fit, when lm() gets it right?
Dear R-help, Here's a simple example of nonlinear curve fitting where nls seems to get the answer wrong on a very simple exponential fit (my R version 2.7.2). Look at this code below for a very basic curve fit using nls to fit to (a) a logarithmic and (b) an exponential curve. I did the fits using self-start functions and I compared the results with a more simple fit using a straight lm()
2005 Apr 23
1
start values for nls() that don't yield singular gradients?
I'm trying to fit a Gompertz sigmoid as follows: x <- c(15, 16, 17, 18, 19) # arbitrary example data here; y <- c(0.1, 1.8, 2.2, 2.6, 2.9) # actual data is similar gm <- nls(y ~ a+b*exp(-exp(-c*(x-d))), start=c(a=?, b=?, c=?, d=?)) I have been unable to properly set the starting value '?'s. All of my guesses yield either a "singular gradient" error if they
2008 Aug 05
1
Fix for nls bug???
Hi All, I've hit a problem using nls. I think it may be a restriction in the applicability of nls and I may have found a fix, but I've been wrong before. This example is simplified to the essentials. My real application is much more complicated. Take a function of matrix 'x' with additional arguments: matrix 'aMat' whose values are _not_ to be determined by nls vector
2008 Aug 18
1
"nested" getInitial calls; variable scoping problems
Hi All, Another nls related problem (for background, I'm migrating a complicated modelling package from S-plus to R). Below I've reduced this to the minimum necessary to demonstrate my problem (I think); the real situation is more complicated. Two similar selfStart functions, ssA and ssB. The 'initial' function for ssB modifies its arguments a little and then calls getInital
2009 Sep 04
1
How should a SelfStart function handle illegal parameter values?
Hi Everyone, I'm trying to write selfStart non-linear models for use with nls. In these models some combinations of parameter values are illegal; the function value is undefined. That's OK when calling the function directly [e.g. SSmodel(x, pars...)]; I return an appropriate non-value such as NA or Inf. However, when called from nls [e.g. nls(y~SSmodel(x, pars...), ...)] those
2006 Feb 01
1
Passing additional paramaters to nlsList(nlme) fit function
Hello, nls-users, is it possible to pass additional parameters to the model function that are known and groupwise constant with nlsList? I could not find something like a "keep this fixed" option in the documentation and the code (my fault...?) The current workaround is to break the problem down into groups and use globals to pass the constant parameters, but it is ugly code and
2006 Jul 18
4
How can I extract information from list which class is nls
Hello! I work with : R : Copyright 2006, The R Foundation for Statistical Computing Version 2.3.1 (2006-06-01) On Windows XP Professional (Version 2002) SP2. At this moment I use the function "nls" combined with a selfStar model (SSmicmen, related to Michaelis-Menten equation, and provided by the "stats" package). When I realise the following operation (cf. p 59 of the