Displaying 20 results from an estimated 3000 matches similar to: "The 'data' argument and scoping in nls"
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
2008 Aug 04
0
Unexpected nls behaviour: Solved
Hi Everyone,
I'd omitted the non-optional 'parameters' argument to selfStart. Making this 
change to SSbatch gives the same (successful) result from the two calls to 
nls.
SSbatch<-selfStart(
model=function(Batch, Coeffs)
{
Coeffs[Batch]
}
,initial=function(mCall, data, LHS)
{
 # Estimate coefficients as mean of each batch
        xy <- sortedXyData(mCall[["Batch"]],
2008 Aug 01
0
Unexpected nls behaviour
Hi everyone,
I thought that for a selfStart function, these two should be exactly 
equivalent
> nls(Aform, DF)
> nls(Aform, DF, start=getInitial(Aform, DF))
but in this example that is not the case in R (although it is in S-plus 
V6.2)
------------------------------
SSbatch<-selfStart(
model=function(Batch, Coeffs)
{
Coeffs[Batch]
}
,initial=function(mCall, data, LHS)
{
 # Estimate
2009 Nov 12
0
writing selfStart models that can deal with treatment effects
Hello,
I'm trying to do some non-linear regression with 2 cell types and 4 tissue 
type treatments using selfStart models
Following Ritz and Streibig (2009), I wrote the following routines:
##Selfstart
expDecayAndConstantInflowModel <- function(Tb0, time, aL, aN, T0){
   exp(-time*aL)*(T0*aL+(-1+exp(time * aL))*Tb0 * aN)/aL
}
expDecayAndConstantInflowModelInit <- function(mCall, LHS,
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
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 Sep 01
1
making self-starting function for nls
Hello.  Following pages 342-347 of Pinheiro & Bates, I am trying to
write a self-starting nonlinear function (a non-rectagular hyperbola) to
be used in nonlinear least squares regression (and eventually for a
mixed model).  When I use the getInitial function for my self-starting
function I get the following error message:
 
> getInitial(photo~NRhyperbola(Irr,theta,Am,alpha,Rd),dat)
Error
2002 Jul 19
1
selfStart function problem
Hello, list,
I am making a self-starting nonlinear function to model the relation of tree height (H) 
and diameter (D) in a forest stand. The function I am trying is
H=a*exp[b*(D+5.8)^(-c)].
To calculate the initial estimates of the parameters, I linearized the formula by taking 
logarithms and fixing the parameter c=1. Then I calculated the initial estimates of a 
and b using lm() on the
2010 Jul 19
1
nls with some coefficients fixed
I'm using nls to fit a variety of different models. Here I use SSgompertz as 
an example.
I want the ability to fix one (or more) of the coefficients that would 
normally be optimised (e.g. fix b3=0.8).
Examples; based on and using data from example(SSgompertz)
#---------------------
# vanilla call to nls, no coefficients fixed, works fine
nls(density ~ SSgompertz(log(conc), Asym, b2, b3),
2009 Jun 09
1
Non-linear regression/Quantile regression
Hi,
I'm relatively new to R and need to do a quantile regression. Linear
quantile regression works, but for my data I need some quadratic function.
So I guess, I have to use a nonlinear quantile regression. I tried the
example on the help page for nlrq with my data and it worked. But the
example there was with a SSlogis model. Trying to write 
dat.nlrq <- nlrq(BM ~ I(Regen100^2),
2010 Apr 15
0
nlsList {nlme} - control arguments problem
Hi Rick
 
Thanks to Dieter Menne I did manage to solve the problem of imposing bounds on
the parameter space duirng an nlsList fit. He suggested using optim to optimize
the parameters prior to each fit. This worked well for me as I had a customized
selfStart function that then optimized the parameters for each individual
separately.
 
if you rewrote your selfStart function as:
 
powrDpltInit <-
2005 Oct 26
0
self starting function for nonlinear least squares.
Following on my posting of this morning, concerning a problem that I am
having constructing a self-starting function for use with nls (and
eventually with nlsList and nlme), the following is the self-starting
function called NRhyperbola:
 
> NRhyperbola
function (Irr,theta,Am,alpha,Rd) 
{
# Am is the maximum gross photosynthetic rate
# Rd is the dark resiration rate (positive value)
#
2010 Apr 12
0
How to derive function for parameters in Self start model in nls
Dear all
i want to fit the self start model in nls. i have two question. i have a
function,
(asfr ~ I(((a*b)/c))+ ((c/age)^3/2)+ exp((-b^2)*(c/age)+(age/c)-2)
i am wondering how to build the selfstart model. there is lost of example,
(i.e. SSgompertz, SSmicman, SSweibull, etc). my question is, how to derive
the function of parameters. and also which model to use for get
the initials values. In the
2006 May 24
1
problem-nlme
Hi,
I have great problems with my work in R.
I look for to model the growth of fish.
I have "Longitudinal data", a serie of repeated
measures for each individual.
Using the corresponding packages "nlme" in R.
I treat to fit to the data different growth functions,
wich were entered by me.
Unfortunately for no it was arrived at the
convergence, several error messages appeared.
I
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
2009 Jun 29
0
nlsList {nlme} - control arguments problem
Hi All.
I'd like to send some control arguments to the nls function when
performing a nlsList analysis.
I'm fitting a power model to some grouped data and would like to
impose lower bounds on the estimates using the "port" algorithm.
Obtaining the lower bound constraint works fine with a direct call to
nls for a single level of the grouping variable. ?However, the bounds
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
2011 Jun 17
2
Non-linear Regression best-fit line
I am trying to fit a curve to a cumulative mortality curve (logistic) where y is the cumulative proportion of mortalities, and t is the time in hours (see below). Asym. at 0 and 1
> y
 [1] 0.00000000 0.04853859 0.08303777 0.15201970 0.40995074 0.46444992 0.62862069 0.95885057 1.00000000
[10] 1.00000000 1.00000000
> t
 [1]  0 13 20 24 37 42 48 61 72 86 90
I tried to find starting values for
2007 Oct 17
2
nmle: gnls freezes on difficult case
Hi,
I am not sure this is a bug but I can repeat it, The functions and data
are below.
I know this is nasty data, and it is very questionable whether a 4pl
model
is appropriate, but it is data fed to an automated tool and I would
have hoped for an error. Does this repeat for anyone else?
My details:
> version
               _                           
platform       i686-pc-linux-gnu          
2003 Jul 24
0
nls.control in gnls
Hi,
I've made a selfStart function for use with gnls and the 
following piece of code works nicely:
check1 <- gnls(y ~ spot.shape.fct(xcord, ycord, background, spotintensity, 
                                  rho, sigma, delta, mux, muy),
              start=getInitial(y ~ spot.shape.fct(xcord, ycord, 
                                   background, spotintensity, rho,