[R] Beginners Question: Make nlm work
jfbrennan at rogers.com
Thu Aug 26 03:06:24 CEST 2004
----- Original Message -----
From: "Johannes Graumann" <johannes_graumann at web.de>
To: <r-help at stat.math.ethz.ch>
Sent: Wednesday, August 25, 2004 7:07 PM
Subject: [R] Beginners Question: Make nlm work
> I'm new to this and am trying to teach myself some R by plotting
> biological data. The growth curve in question is supposed to be fitted
> to the Verhulst equation, which may be transcribed as follows:
> - for a known population density (0.008) at t(0).
> I am trying to rework the example from "An Introduction to R" (p. 72)
> for my case and am failing miserably. Could somebody glance over the
> code below and nudge me into the right direction - I must have some
> major conceptual problem which can't be solved by me staring at it ...
> Since I'm repeating something I have done with gnuplot I know that 3 and
> 4e-3 as starting values for the fit are appropriate ...
> Thanks for any hint,
> VH <- function(p) y ~ p/(1+((p-0.008)/0.008)*exp(-(p*x)))
Shouldn't this be
VH <- function(p) sum((y - p/(1+((p-0.008)/0.008)*exp(-(p*x))))^2)
Where you are minimizing the squared deviations from what your given
equation is when you pass it to nlm?
Maybe if you send some data that would make it more clear.
> plot(x, y, xlab="Time (h)",ylab=expression(OD[~nm]),las=1)
> out <- nlm(VH, p = c(3, 4e-3), hessian = TRUE)
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide!
More information about the R-help