[R] Help fit 5 nonlinear models. - Plant growth curves

From: Alejandro Coca Castro <acocac_at_gmail.com>
Date: Tue, 17 May 2011 07:32:13 -0300


Hi!! Can anyone help me, i have problems to converge the following data with 5 nonlinears models that i evaluated.

Firtly, i send my data (totalsinatipicos) that i just try to fit with the nonlinear models.

Next, i have the following script where i called the data as totalsinatipicos. I made selfstarting each nonlinear model.

###Library

library(NRAIA)
###Data

d<-totalsinatipicos
f=unique(d$TRAT)
dia=unique(d$DDT)
REG=4:15
###Models

monomolecular=function(x,a,b,c){return(a*(1-exp(-b*(x-c))))} gompertz=function(x,a,b,c){return(a*exp(-exp(-b*(x-c))))} logistico=function(x,a,b,c){return(a/(1+exp(-b*(x-c))))} gauss=function(x,a,b,c){return(a*exp((-((x-c)*(x-c))/(2*(b*b)))))} richards=function(x,a,b,c){return(a*(1+(m-1)*exp(-b*(x-c)))**(1/(1-m)))}
###Variables
#Altura

ALTURA0=subset(d,d$TRAT==f[1],select=c(1,REG[1])) ALTURA_0=data.frame(dia,tapply(ALTURA0[,2],ALTURA0[,1],median, na.rm=TRUE)) colnames(ALTURA_0)=c("ddt","reg")
#PSEUDO

PSEUDO0=subset(d,d$TRAT==f[1],select=c(1,REG[5])) PSEUDO_0=data.frame(dia,tapply(PSEUDO0[,2],PSEUDO0[,1],median, na.rm=TRUE)) colnames(PSEUDO_0)=c("ddt","reg")
#DIAM

DIAM0=subset(d,d$TRAT==f[1],select=c(1,REG[6])) DIAM_0=data.frame(dia,tapply(DIAM0[,2],DIAM0[,1],median, na.rm=TRUE)) colnames(DIAM_0)=c("ddt","reg")
#AF

AF0=subset(d,d$TRAT==f[1],select=c(1,REG[7])) AF_0=data.frame(dia,tapply(AF0[,2],AF0[,1],median, na.rm=TRUE)) colnames(AF_0)=c("ddt","reg")
#PSB

PSB0=subset(d,d$TRAT==f[1],select=c(1,REG[8])) PSB_0=data.frame(dia,tapply(PSB0[,2],PSB0[,1],median, na.rm=TRUE)) colnames(PSB_0)=c("ddt","reg")
#PSA

PSA0=subset(d,d$TRAT==f[1],select=c(1,REG[11])) PSA_0=data.frame(dia,tapply(PSA0[,2],PSA0[,1],median, na.rm=TRUE)) colnames(PSA_0)=c("ddt","reg")
#PST

PST0=subset(d,d$TRAT==f[1],select=c(1,REG[12])) PST_0=data.frame(dia,tapply(PST0[,2],PST0[,1],median, na.rm=TRUE)) colnames(PST_0)=c("ddt","reg")

For example, i show the converge error for each variable for fitting logistic model. In some cases, apparently the model works but it doesnt show the number of iterations. Also, i put lower and upper values, after graph each variable and estimate these with the data behavior.


summary(ALTU <- nls(reg ~ logistico(ddt,a,b,c), ALTURA_0,
start=c(a=1.00001,b=0.00001,c=1.00001),algorithm = "port",
lower=c(a=10,b=0.1,c=40), upper=c(a=71,b=0.5,c=80)))

Error en nls(reg ~ logistico(ddt, a, b, c), ALTURA_0, start = c(a = 1.00001, :   Convergence failure: initial par violates constraints

summary(AF <- nls(reg ~ logistico(ddt,a,b,c), AF_0,
start=c(a=1.000001,b=0.000001,c=1.000001),algorithm = "port",
lower=c(a=0.01,b=0,c=0.01)), upper=c(a=700,b=0.5,c=90))

Error en nls(reg ~ logistico(ddt, a, b, c), AF_0, start = c(a = 1.000001, :   Convergence failure: singular convergence (7)

summary(PSEUDO <- nls(reg ~ logistico(ddt,a,b,c), PSEUDO_0,
start=c(a=1.000001,b=0.000001,c=50),algorithm = "port",
lower=c(a=0.01,b=0,c=50)), upper=c(a=2,b=0.5,c=90))

Formula: reg ~ logistico(ddt, a, b, c)

Parameters:

   Estimate Std. Error t value Pr(>|t|)

a   2.26458    2.95827   0.766    0.500
b   0.02780    0.04687   0.593    0.595
c  50.00000  102.68111   0.487    0.660

Residual standard error: 0.3078 on 3 degrees of freedom

Algorithm "port", convergence message: relative convergence (4)

summary(DIAM <- nls(reg ~ logistico(ddt,a,b,c), DIAM_0,
start=c(a=1.000001,b=0.000001,c=1.000001),algorithm = "port",
lower=c(a=0.01,b=0,c=0.01)), upper=c(a=10,b=0.5,c=90))

Formula: reg ~ logistico(ddt, a, b, c)

Parameters:
  Estimate Std. Error t value Pr(>|t|)

a  9.68748    0.93912  10.315 0.001943 **
b  0.07290    0.01345   5.419 0.012326 *
c 56.38424    3.92957  14.349 0.000734 ***
---
Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1   1

Residual standard error: 0.4382 on 3 degrees of freedom

Algorithm "port", convergence message: relative convergence (4)

summary(PSB <- nls(reg ~ logistico(ddt,a,b,c), PSB_0,
start=c(a=1.000001,b=0.000001,c=1.000001),algorithm = "port",
lower=c(a=0.01,b=0,c=0.01)), upper=c(a=18,b=0.5,c=90))

Formula: reg ~ logistico(ddt, a, b, c)

Parameters:
   Estimate Std. Error t value Pr(>|t|)
a 18.367752   0.680799   26.98 0.000112 ***
b  0.100945   0.005831   17.31 0.000420 ***
c 69.990010   1.006649   69.53 6.56e-06 ***
---
Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1   1

Residual standard error: 0.208 on 3 degrees of freedom

Algorithm "port", convergence message: relative convergence (4)

summary(PSA <- nls(reg ~ logistico(ddt,a,b,c), PSA_0,
start=c(a=1.000001,b=0.000001,c=1.000001),algorithm = "port",
lower=c(a=0.01,b=0,c=0.01)), upper=c(a=7,b=0.5,c=90))

Formula: reg ~ logistico(ddt, a, b, c)

Parameters:
  Estimate Std. Error t value Pr(>|t|)
a  6.19659    0.42597  14.547 0.000704 ***
b  0.08874    0.01776   4.995 0.015432 *
c 49.10031    2.86108  17.161 0.000431 ***
---
Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1   1

Residual standard error: 0.351 on 3 degrees of freedom

Algorithm "port", convergence message: relative convergence (4)

summary(PST <- nls(reg ~ logistico(ddt,a,b,c), PST_0,
start=c(a=1.000001,b=0.000001,c=1.000001),algorithm = "port",
lower=c(a=0.01,b=0,c=0.01)), upper=c(a=26,b=0.5,c=90),
control=nls.control(maxiter=1))

Formula: reg ~ logistico(ddt, a, b, c)

Parameters:
   Estimate Std. Error t value Pr(>|t|)
a 27.950304   1.770967  15.783 0.000553 ***
b  0.081335   0.008213   9.903 0.002190 **
c 64.257293   2.168668  29.630 8.44e-05 ***
---
Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1   1

Residual standard error: 0.6266 on 3 degrees of freedom

Algorithm "port", convergence message: relative convergence (4)

-----------------------------------------------------------------------

Finally, my next step is to automatized the process, with loops, for
running each variable with each model in each treatment, which are 4,
but i am beginner in R program. Can anyone give a idea about it?.

Also, i just tried to use SSmodels, like SSlogis, SSgompertz and
SSRichards, but i have models as monomolecular and gauss function that
aren't defined in this algoritms.

Thanks for your help or suggestions.

-- 
Alejandro Coca
UN

______________________________________________ R-help_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

Received on Tue 17 May 2011 - 10:37:54 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 17 May 2011 - 10:40:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive