Adjustment of sigmoidal growth curves in R

1

I am trying to adjust a curve of accumulation of nutrients and dry matter of corn in R. I know that the curve that it describes is sigmoidal and that the accumulation of dry matter or nutrients depends on time. My first question is how I adjust and graph this in R and then, having several curves of different treatments, how I compare the curves between them. I pass something of what I wrote in R and some data in a link:

dataT1 <- subset(C, Trat == "T1")
dataT3 <- subset(C, Trat == "T3")
dataT7 <- subset(C, Trat == "T7")

plotPoints(MS ~ Dia, data = dataT1)

MST1 <- nls(MS ~ a + ((b - a)/(1 + exp(-c * (Dia - d)))), data = dataT1, start = list(a = min(MS), 
                                                                   b = max(Dia), c = 1, d = round(median(MS))), trace = TRUE)

When I write this, I miss the error Error in typeof(x) : objeto 'MS' no encontrado

Database: link

Thank you very much!

    
asked by germanfernandez 04.11.2017 в 21:09
source

2 answers

1

I respond promptly to the error you are having. You have the problem in the start parameter, you are building a list of initial values, but you have to keep in mind that this list object is outside the scope of nls() , so that the parameter data = dataT1 does not mean anything to the list, you must build the invocation in the following way:

MST1 <- nls(MS ~ a + ((b - a)/(1 + exp(-c * (Dia - d)))), 
            data = dataT1, 
            start = list(a = min(dataT1$MS), 
                      b = max(dataT1$Dia), 
                      c = 1, 
                      d = round(median(dataT1$MS))
                      ), 
            trace = TRUE)

That is, specifying the complete "path" to the object, that is, dataT1$MS or dataT1$Dia ). Anyway, at least with the data you have published, you have another error, but in this case with the choice of the initial values, that in any case you will have to analyze it.

    
answered by 06.11.2017 / 04:58
source
0

I found the answer with this code:

plotPoints(MS ~ Dia, data = dataT1)
MST1 <- nls(MS ~ a + ((b - a)/(1 + exp(-c * (Dia - d)))),
            data = dataT1,
            start = list(a = min(dataT1$MS),
                         b = max(dataT1$MS),
                         c = 1, d = median(dataT1$Dia)),
            trace = TRUE, algorithm = "port")

overview(MST1)
plotfit(MST1, smooth = TRUE)

Thank you very much to all the people who gave me a hand.

    
answered by 06.11.2017 в 16:15