Hello,

*Here it is a copy of my data:*

>dput(head(DATA,4))
structure(list(Date = structure(c(13L, 13L, 13L, 13L), .Label =
c("02/09/2010",
"05/07/2010", "05/08/2010", "07/09/2010", "10/08/2010", "13/07/2010",
"14/09/2010", "19/08/2010", "20/09/2010", "22/07/2010", "27/07/2010",
"27/08/2010", "30/06/2010"), class = "factor"), Dateennb = c(40359L,
40359L, 40359L, 40359L), Plante = structure(c(2L, 3L, 6L, 7L), .Label =
c("A11",
"A50", "A64", "B22", "B33", "B41", "B68", "C15", "C42", "C56",
"D35", "D47", "D68", "D7", "E20", "E40", "E66", "F21", "F30",
"F47", "F5", "F60", "G23", "G37", "G47", "G67", "G9", "H32",
"H64", "H7"), class = "factor"), JourJulien = c(181L, 181L, 181L,
181L), Traitement = structure(c(2L, 2L, 2L, 2L), .Label = c("Control",
"Shade", "Water stress"), class = "factor"), Hauteur = c(75.5,
84, 87, 84), NbFeuil.sup.2cm = c(21L, 20L, 19L, 20L), Nbbq.sup.50. = c(2L,
1L, 2L, 2L), Nb_phyto = c(25.38362514, 24.17488109, 22.96613704,
24.17488109)), .Names = c("Date", "Dateennb", "Plante", "JourJulien",
"Traitement", "Hauteur", "NbFeuil.sup.2cm", "Nbbq.sup.50.", "Nb_phyto"
), row.names = c(NA, 4L), class = "data.frame")

*I also post my data here (be careful, it's a .xls file)*
http://www.fichier-xls.fr/2012/03/06/7gvwshi/*

The code used is as follow:*

rm(list=ls(all=TRUE))
PATH <- "/home/ampinet/workspace/Data/"

fname <- "Phyllochrone_AP.csv"
DATA    <-
read.table(file=paste(PATH,fname,sep=""),header=T,sep=";",dec=",")


# broken line with no effet of traitement
dbleseg0 <- function (JourJulien,a0,b0,a1,T) (a0*JourJulien+b0) +
a1*(JourJulien >T)*(T-JourJulien)

# broken line with effet of traitement on a0 parameter
dbleseg1 <- function (JourJulien,a0,b0,a1,T,a0a) {
    (((a0+a0a*(DATA$Traitement!="Control"))*JourJulien)+b0) +
a1*(JourJulien >T)*(T-JourJulien)
}

# broken line with effet of traitement on b0 parameter
dbleseg2 <- function (JourJulien,a0,b0,a1,T,b0a) {
    ((a0*JourJulien)+(b0+b0a*(DATA$Traitement!="Control"))) +
a1*(JourJulien >T)*(T-JourJulien)
                }

# broken line with effet of traitement on a0 and b0 parameters
dbleseg3 <- function (JourJulien,a0,b0,a1,T,a0a,b0a) {

(((a0+a0a*(DATA$Traitement!="Control"))*JourJulien)+(b0+b0a*(DATA$Traitement!="Control")))
+ a1*(JourJulien >T)*(T-JourJulien)
}

a0init <- 0.49
b0init <- -65
a1init <- 0.30
Tinit <- 239
a0ainit <--0.40
b0ainit <- 6
a1ainit <--0.1

library(nlme)

Mod1 <- nls(Nb_phyto ~dbleseg0(JourJulien,a0,b0,a1,T),data =
DATA,start=c(a0=a0init,b0=b0init,a1=a1init,T=Tinit),na.action=na.omit)

Mod2 <- nls(Nb_phyto ~dbleseg1(JourJulien,a0,b0,a1,T,a0a),data =
DATA,start=c(a0=a0init,b0=b0init,a1=a1init,T=Tinit,a0a=a0ainit),na.action=na.omit)

Mod3 <- nls(Nb_phyto ~dbleseg2(JourJulien,a0,b0,a1,T,b0a),data =
DATA,start=c(a0=a0init,b0=b0init,a1=a1init,T=Tinit,b0a=b0ainit),na.action=na.omit)

Mod4 <- nls(Nb_phyto ~dbleseg3(JourJulien,a0,b0,a1,T,a0a,b0a),data =
DATA,start=c(a0=a0init,b0=b0init,a1=a1init,T=Tinit,a0a=a0ainit,b0a=b0ainit),na.action=na.omit)

*Mod2, Mod3, Mod4 ran but I obtained this warnings:
Il y a eu 50 avis ou plus (utilisez warnings() pour voir les 50 premiers)

Then I tried to use nlme()* (with the same start values) :

dataAna <- groupedData(Nb_phyto ~1|Plante,data=DATA)

Mod5 <- nlme(Nb_phyto ~dbleseg0(JourJulien,a0,b0,a1,T),data =
dataAna,fixed=a0+b0+a1+T~1,random=pdDiag(b0~1),start=c(a0=a0init,b0=b0init,a1=a1init,T=Tinit),na.action=na.omit)

Mod6 <- nlme(Nb_phyto ~dbleseg1(JourJulien,a0,b0,a1,T,a0a),data =
dataAna,fixed=a0+b0+a1+T+a0a~1,random=pdDiag(a0~1),start=c(a0=a0init,b0=b0init,a1=a1init,T=Tinit,a0a=a0ainit),na.action=na.omit)
*
Mod5 ran but it was not the case for Mod6:*
Erreur dans X[, fmap[[nm]]] <- gradnm :
  le nombre d'objets à remplacer n'est pas multiple de la taille du
remplacement
De plus : Il y a eu 47 avis (utilisez warnings() pour les visionner)

*gradnm is called in nlme function; however I am not able to disentangle
its role in nlme function...*

Thanks in advance for your responses


Amélie

2012/3/2 Ben Bolker <bbolker@gmail.com>

> amelie pinet <amelie.pinet@...> writes:
>
> >
> > Hello,
> > When using nlme () function I have a error message that I don't
> understand:
> >
> > Mod2 <- nlme(Nb_phyto ~dbleseg1(JourJulien,a0,b0,a1,T,a0a),data =
> > dataAna,fixed=a0+b0+a1+T+a0a~1,
> > random=pdDiag(b0~1),
> >
> start=c(a0=a0init,b0=b0init,a1=a1init,T=Tinit,a0a=a0ainit),na.action=na.omit)
> >
> > Erreur dans X[, fmap[[nm]]] <- gradnm :
> >   le nombre d'objets à remplacer n'est pas multiple de la taille du
> > remplacement
> > De plus : Il y a eu 47 avis (utilisez warnings() pour les visionner)
>
>
>   It's hard to answer without a reproducible example:
> http://tinyurl.com/reproducible-000 ... the problem *could* be inside
> your dbleseg1 function.  Does it work outside of nls/nlme?  Are there
> any simplified versions that you have gotten to work?
>
> > I use the following packages:
> >
> > R version 2.11.1 (2010-05-31)
> > x86_64-pc-linux-gnu
> > nlme_3.1-96 rj_1.0.3-7
> >
>
>  It's not necessarily *the* problem, but it would generally be advised
> to update to a more recent version of nlme -- especially if we have
> trouble reproducing your problem with more recent versions.
>
>  You can use traceback() to try to see where the error came from,
> although it's probably pretty deep within a nested set of function
> calls ...
>
> _______________________________________________
> R-sig-mixed-models@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>



-- 
Dr. Pinet Amélie
INRA, Plantes et Systèmes de culture Horticoles
Domaine St Paul, Site Agroparc, 84941 Avignon Cedex 9, France

	[[alternative HTML version deleted]]


