Displaying 20 results from an estimated 20000 matches similar to: "nls and R scoping rules"
2012 Jul 03
1
nls problem
hi list,
used versions: 2.12.1 and 2.14.0 under ubuntu and macosx.
I recently stumbled over a problem with `nls', which occurs if the model
is not specified explicitly but via an evaluation of a 'call' object.
simple example:
8<--------------------------------------------------------------------------------------
nlsProblem <- function (len = 5) {
2004 Oct 25
1
Scoping and nls.
A colleague of mine is trying to use nls() to effect an optimization,
and is encountering a scoping problem. I should know how to solve it
for him but .... well, I just don't.
I also had a quick scrounge of the archives --- I know I've seen this
topic addressed before --- but I couldn't track it down.
So here's a toy example that demonstrates the problem:
hhh <-
2004 Jun 03
5
Confidence intervals for predicted values in nls
Dear all
I have tried to estimate the confidence intervals for predicted values of a
nonlinear model fitted with nls. The function predict gives the predicted
values and the lower and upper limits of the prediction, when the class of
the object is lm or glm. When the object is derived from nls, the function
predict (or predict.nls) gives only the predicted values. The se.fit and
interval aguments
2009 Dec 18
2
NLS-Weibull-ERROR
Hello
I was trying to estimate the weibull model using nls after putting OLS
values as the initial inputs to NLS.
I tried multiple times but still i m getting the same error of Error in
nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates.
The Program is as below
> vel <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14)
> df <- data.frame(conc, vel)
>
2006 Sep 15
1
Formula aruguments with NLS and model.frame()
I could use some help understanding how nls parses the formula argument
to a model.frame and estimates the model. I am trying to utilize the
functionality of the nls formula argument to modify garchFit() to handle
other variables in the mean equation besides just an arma(u,v)
specification.
My nonlinear model is
y<-nls(t~a*sin(w*2*pi/365*id+p)+b*id+int,data=t1,
2005 Jun 01
1
nls(() and trace
hi everybody,
is there a canonical way to get hold of the "trace=TRUE" output from
nls, i.e. to copy it to a R variable (or at least to an external log file)?
I have only found the possibility to "fix(nlsModel)" (and than the
correct copy of that: namespace function ...) within the R-session by
modifying the trace() definition within nlsModel. not really good for
everyday
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 Aug 25
3
Covariates in NLS (Multiple nonlinear regression)
Dear R-users,
I am trying to create a model using the NLS function, such that:
Y = f(X) + q + e
Where f is a nonlinear (Weibull: a*(1-exp(-b*X^c)) function of X and q is a covariate (continous variable) and e is an error term. I know that you can create multiple nonlinear regressions where x is polynomial for example, but is it possible to do this kind of thing when x is a function with unknown
2011 Nov 30
2
nls help
Hello,
I have data like the following:
datum <- structure(list(Y = c(415.5, 3847.83333325, 1942.833333325,
1215.22222233333,
950.142857325, 2399.5833335, 804.75, 579.5, 841.708333325, 494.053571425
), X = c(1.081818182, 0.492727273, 0.756363636, 0.896363636,
1.518181818, 0.499166667, 1.354545455, 1.61, 1.706363636, 1.063636364
)), .Names = c("Y", "X"), row.names = c(NA,
2010 Mar 30
6
Error "singular gradient matrix at initial parameter estimates" in nls
I am using nls to fit a non linear function to some data.
The non linear function is:
y= 1- exp(-(k0+k1*p1+ .... + kn*pn))
I have chosen algorithm "port", with lower boundary is 0 for all of the
ki parameters, and I have tried many start values for the parameters ki
(including generating them at random).
If I fit the non linear function to the same data using an external
2004 May 21
1
Buglet/omission in nls package (PR#6901)
Dear all,
I noticed the following under R 1.8.1 (when nls was still a separate
package) but the same problem occurs under R 1.9.0 (where most (all?)
of nls is now in the stats package):
> data(Puromycin)
> fm <- nls(rate~SSmicmen(conc,b0,b1), Puromycin, subset = state=="treated")
> coef(summary(fm))
NULL
The problem seems to be that summary.nls uses the name
2011 Jun 30
1
Error "singular gradient matrix at initial parameter estimates" in nls
Greetings,
I am struggling a bit with a non-linear regression. The problem is
described below with the known values r and D inidcated.
I tried to alter the start values but get always following error
message:
Error in nlsModel(formula, mf, start, wts):
singular gradient matrix at initial parameter estimates
Calls: nls -> switch -> nlsModel
I might be missing something with regard to the
2005 Apr 06
1
nls.control
Hello everyone,
I'm trying to test the accurracy of R on the Eckerle4 dataset from NIST and
I don't understand how the control option of the nls function works.
I tought nls(...) was equivalent to nls(...control=nls.control()) i.e nls.control() was the default value of control, but here is the error I get :
> n2=nls(V1~(b1/b2) *
2010 Aug 13
2
Unable to retrieve residual sum of squares from nls output
Colleagues,
I am using "nls" successfully (2.11.1, OS X) but I am having difficulties retrieving part of the output - residual sum of squares. I have assigned the output to FIT:
> > FIT
> Nonlinear regression model
> model: NEWY ~ PMESOR + PAMPLITUDE * cos(2 * pi * (NEWX - POFFSET)/PERIOD)
> data: parent.frame()
> PMESOR PAMPLITUDE POFFSET
>
2013 Mar 14
2
question about nls
Hi,all:
I met a problem of nls.
My data:
x y
60 0.8
80 6.5
100 20.5
120 45.9
I want to fit exp curve of data.
My code:
> nls(y ~ exp(a + b*x)+d,start=list(a=0,b=0,d=1))
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
I can't find out the reason for the error.
Any suggesions are welcome.
Many thanks.
[[alternative HTML
2010 Apr 28
1
NLS "Singular Gradient" Error
Hello,
I am trying to model a type II functional response of number of prey eaten
(Ne) against number supplied (No) with a non-linear least squares regression
(nls). I am using a modification of Holling's (1959) disc equation to
account for non-replacement of prey;
Ne=No{1-exp[a(bNe-T)]}
where a is the attack rate, b is the handling time, and T is the
experimental period.
My script is as
2003 Dec 15
1
nls arguments
Hi all,
I've got a problem with the nls function.
I have an adjustment which works when I fix one of the argument of my
function (Xo=150) :
*Xo*=150
f<- function (tt*,Xo*,a,b) ifelse(tt<*Xo*,a*exp(-b**Xo*),a*exp(-b*tt))
ajust<-nls(RER~f(tt,*Xo*,a,b),data=data.frame(tt=Ph2[,2*k],RER=Ph2[,2*k+1]),start=list(a=0.5,b=0.014))
But, when I use it as a "normal" parameter (and
2004 Oct 07
1
confidence interval for nls
Do I have the right impression that it's currently not possible to
produce confidence intervals for the nls predictions using R?
I had a course were we used SAS PROC nlin and there you could get
intervals for the parameters and the prediction but I do not have access
to SAS.
Would it be difficult to implement, I tried to dig into the help pages
of nls, vcov and nlsModel but I could not
2010 Jan 13
1
Problem fitting a non-linear regression model with nls
Hi,
I'm trying to make a regression of the form :
formula <- y ~ Asym_inf + Asym_sup * ( (1 / (1 + (n1 * (exp( (tmid1-x)
/ scal1) )^(1/n1) ) ) ) - (1 / (1 + (n2 * (exp( (tmid2-x) / scal2)
)^(1/n2) ) ) ) )
which is a sum of the generalized logistic model proposed by richards.
with data such as these:
x <- c(88,113,128,143,157,172,184,198,210,226,240,249,263,284,302,340)
y <-
2011 Jun 12
2
NLS fit for exponential distribution
Hello there,
I am trying to fit an exponential fit using Least squares to some data.
#data
x <- c(1 ,10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
y <- c(0.033823, 0.014779, 0.004698, 0.001584, -0.002017, -0.003436,
-0.000006, -0.004626, -0.004626, -0.004626, -0.004626)
sub <- data.frame(x,y)
#If model is y = a*exp(-x) + b then
fit <- nls(y ~ a*exp(-x) + b, data = sub, start