1
$\begingroup$

I would like to identify the significance of the difference between two growth curves with the same formula but different parameters. The dummy data generated by the code produces a normal spread of values for each x increment giving two curves that are visually distinct. I suspect there is no clear cut 'best' solution but comments would be welcome. I am not keen on the transform -> lm route.

Thanks.

library(car)
library(nls)
#### Make some tree growth data according to height ~ 1.3 + (theta1 * DiaBH)/(theta2 + DiaBH)
dbh <-seq(from=1,to= 75, by =5)
pines <-data.frame(1.3,0,"") # starter data frame
names(pines) <-c("height","DiaBH","Species")
a <- 22 # theta1 for P.peuce
b <- 10 # theta2 for P.peuce
c <- 25 # theta 1 for P.Sitch
d <- 30 # theta2 for P.sitch
### Assume a normal distribution and build a random 
### data set of heights for each increment of DiaBH for each species
for(i in 1:length(dbh)){
  hs <- rnorm(8, 1.3+((dbh[i]*a)/(b + dbh[i])),.8)
  ds <- rep(dbh[i],8)
  ns <- rep("P.Peuce",8)
  hsdsns <-as.data.frame(cbind(hs,ds,ns))
  names(hsdsns) <-c("height","DiaBH","Species")
  pines <-rbind(pines,hsdsns)
  hs <- rnorm(8, 1.3+((dbh[i]*c)/(d + dbh[i])),.8)
  ds <- rep(dbh[i],8)
  ns <- rep("P.Sitch",8)
  hsdsns <-as.data.frame(cbind(hs,ds,ns))
  names(hsdsns) <-c("height","DiaBH","Species")
  pines <-rbind(pines,hsdsns)
}
pines <-pines[-1,] # strip off the starter row
pines$height <-as.numeric(pines$height)
pines$DiaBH <-as.numeric(pines$DiaBH)
pines$Sp <-Recode(pines$Species, "'P.Peuce'=1;'P.Sitch'=0 ")
pines$Sp <-factor(pines$Sp) # remove unwanted levels
pines$Species <- factor(pines$Species) # remove unwanted levels

### Plot shows the two curves to be visually distinct #######################
sp <-scatterplot(main="Comparison of Growth Rates",
                 legend.coords = "bottomright", x = pines$DiaBH,y=pines$height,
                 xlab = "Diameter at Breast Height (cm)", ylab="Height (M)",
                 groups = pines$Species,reg.line = FALSE,legend.title = "Species")

#### nls analysis ###########################################################
with(pines, table(Sp))
### Firstly all together
pines.nls.1 <- nls(height ~ 1.3 + ((DiaBH*theta1)/(theta2+DiaBH)), 
                   pines, start = list(theta1=40, theta2=40))
summary(pines.nls.1)
bs <-coef(pines.nls.1)
### Then by species
pines.nls.2 <- nls(height ~ 1.3 + ((DiaBH*theta1[Sp])/(theta2[Sp]+DiaBH)), pines,
              start = list(theta1=rep(bs[1],2), theta2=rep(bs[2],2)))
summary(pines.nls.2)
### or alternatively...
library(statmod)
compareGrowthCurves(pines$Species,as.matrix(pines$height),nsim = 10000)
$\endgroup$
1
$\begingroup$

I'm not sure what exactly is meant by "significance of the difference between two growth curves". nlme::gnls fits can be used to test significance of parameter differences:

library(nlme)
fit <- gnls(height ~ 1.3 + ((DiaBH*theta1)/(theta2+DiaBH)), 
            pines, start = list(theta1=c(40, 0), theta2=c(40, 0)),
            params = theta1 + theta2 ~ Sp)
summary(fit)$tTable

                        Value Std.Error    t-value       p-value
theta1.(Intercept)  24.142765 0.5171966  46.680050 3.597291e-121
theta1.Sp1          -1.887628 0.5714321  -3.303328  1.103850e-03
theta2.(Intercept)  27.601700 1.4718774  18.752717  1.179388e-48
theta2.Sp1         -17.054024 1.5450285 -11.037999  4.113452e-23

If you have repeated measures, you should use nlme::nlme instead.

If you really want to show that both curves are "significantly different", I'd suggest plotting bootstrap confidence bands.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.