[R] Beginners Question: Make nlm work
Arne Henningsen
ahenningsen at email.uni-kiel.de
Thu Aug 26 10:13:06 CEST 2004
Hi,
did you try "nls" (nonlinear least squares)? "?nlm" says:
"For nonlinear regression, 'nls' may be better".
Another option would be "optim".
Best wishes,
Arne
On Thursday 26 August 2004 01:07, Johannes Graumann wrote:
> Hello,
>
> 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:
> f(x)=a/(1+((a-0.008)/0.008)*exp(-(b*x)))
> - 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,
>
> Joh
>
> setwd("~/Biology/R_versuch")
> mydata<-read.table("YJG45-7_Growth.dat")
> x<-mydata$V1
> y<-mydata$V2
> VH <- function(p) y ~ p[1]/(1+((p[1]-0.008)/0.008)*exp(-(p[2]*x)))
> plot(x, y, xlab="Time (h)",ylab=expression(OD[600][~nm]),las=1)
> out <- nlm(VH, p = c(3, 4e-3), hessian = TRUE)
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
--
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
ahenningsen at agric-econ.uni-kiel.de
http://www.uni-kiel.de/agrarpol/ahenningsen/
More information about the R-help
mailing list