David: Note that your problem is linear so it looks like you can use the lm
function to estimate a, b and c. ( or as a check against what john
did ) Unless I'm missing something which could be the case ! Also, see
Bloomfield's text for a closed form solution. I think it's
called "Intro To Four
Dear David,
I'm afraid that this doesn't make much sense -- that is, I expect that
you're not doing what you intended.
First, sin(2*pi*t) and cos(2*pi*t) are each invariant:
> sin(2*pi*t)
[1] -2.449294e-16 -4.898587e-16 -7.347881e-16 -9.797174e-16
-1.224647e-15 -1.469576e-15
[7] -1.714506e
Use nlsr::nlxb() to get analytic derivatives. Though your problem is pretty
rubbishy --
look at the singular values. (You'll need to learn some details of nlxb()
results to
interpret.)
Note to change the x to t in the formula.
JN
> f1 <- y ~ a+b*sin(2*pi*t)+c*cos(2*pi*t)
> res1 <- nls(f1, dat
I'm trying to fit a harmonic equation to my data, but when I'm applying the
nls function, R gives me the following error:
Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at
initial parameter estimates.
All posts I've seen, related to this error, are of exponential function
It seems to work!
Thanks and sorry for the personal message
Francisco
On Tue, 17 Apr 2012 09:09:24 +0200, peter dalgaard wrote
> On Apr 17, 2012, at 06:23 , Francisco Mora Ardila wrote:
>
> > Hi
> >
> > I´m trying to fit a nonlinear model to a derivative of the logistic function
> >
> > y = a
2 1.080
residual sum-of-squares: 50.5
Number of iterations to convergence: 0
Achieved convergence tolerance: 4.818e-07
>
On 04/17/2012 06:00 AM, r-help-requ...@r-project.org wrote:
> Message: 112
> Date: Mon, 16 Apr 2012 23:23:07 -0500
> From: "Francisco Mora Ardila"
>
On Tue, Apr 17, 2012 at 12:23 AM, Francisco Mora Ardila
wrote:
> Hi
>
> I´m trying to fit a nonlinear model to a derivative of the logistic function
>
> y = a/(1+exp((b-x)/c)) (this is the parametrization for the SSlogis function
> with nls)
>
> The derivative calculated with D function is:
>
>>
On Apr 17, 2012, at 06:23 , Francisco Mora Ardila wrote:
> Hi
>
> I´m trying to fit a nonlinear model to a derivative of the logistic function
>
> y = a/(1+exp((b-x)/c)) (this is the parametrization for the SSlogis function
> with nls)
>
> The derivative calculated with D function is:
>
>> l
Hi
I´m trying to fit a nonlinear model to a derivative of the logistic function
y = a/(1+exp((b-x)/c)) (this is the parametrization for the SSlogis function
with nls)
The derivative calculated with D function is:
> logis<- expression(a/(1+exp((b-x)/c)))
> D(logis, "x")
a * (exp((b - x)/c) * (1
You need better starting values. Try setting b3=1 and solving using
lm using that result as your starting values in nls:
> cc <- coef(lm(log(q1)~d1,data=x))
> cc <- c(cc, 1)
> names(cc) <- c("b1", "b2", "b3")
> nls(log(q1)~b1+(b2/b3)*(d1^b3-1),data=x,start=cc,trace=TRUE)
225.0784 : 1.515604 4.32
Hallo HelpeRs,
I try to reconstruct some results from an econometric text book
(Heij et al. (2004), pp. 218-20).
For the data
> x <- structure(list(q1 = c(345, 331, 320, 314, 299, 395, 415,
490, 547, 656, 628, 627), d1 = c(1, 1, 1, 1, 1, 1, 1.05,
1.05, 1.05, 1.15, 1.15, 1.15)), .Names =
11 matches
Mail list logo