First recreate the plots and curves for July 12 that Hannah sent me. Read in the data. Notice it needs to be in long format. I manually edited the spreadsheet you sent me. The head() function prints the first 6 rows of data.

library(readxl)
d <- read_xlsx("ExampleData.xlsx", sheet = 2)
# set morning as baseline level
d$time <- factor(d$time, levels = c("morning", "afternoon"))
head(d)
## # A tibble: 6 × 3
##     par   gpp time   
##   <dbl> <dbl> <fct>  
## 1  150.  3.66 morning
## 2  348.  5.70 morning
## 3  467.  7.43 morning
## 4  567   8.92 morning
## 5  704. 14.7  morning
## 6  889. 13.5  morning

Now fit models for morning and afternoon using the nls() function. The SSmicen() function is a self-starting Michaelis-Menten Model. This model is parameterized like the GPP model.

\[ Y = \frac{aX}{b + X} = \frac{GPP_{max}X}{KI + X} \]

# morning model
fit_am <- nls(gpp ~ SSmicmen(par, gpp_max, KI), 
              data = subset(d, time == "morning"))
fit_am
## Nonlinear regression model
##   model: gpp ~ SSmicmen(par, gpp_max, KI)
##    data: subset(d, time == "morning")
## gpp_max      KI 
##   19.26  573.77 
##  residual sum-of-squares: 27.33
## 
## Number of iterations to convergence: 0 
## Achieved convergence tolerance: 4.371e-06
# afternoon model
fit_pm <- nls(gpp ~ SSmicmen(par, gpp_max, KI), 
              data = subset(d, time == "afternoon"))
fit_pm
## Nonlinear regression model
##   model: gpp ~ SSmicmen(par, gpp_max, KI)
##    data: subset(d, time == "afternoon")
## gpp_max      KI 
##   19.83 1514.84 
##  residual sum-of-squares: 0.623
## 
## Number of iterations to convergence: 0 
## Achieved convergence tolerance: 8.637e-08

Now recreate the plot.

plot(d$par, d$gpp, 
     col = ifelse(d$time == "morning", "cornflowerblue", "salmon"), pch = 19)
curve((19.26 * x)/(573.77 + x), add = TRUE, 
      col = "cornflowerblue")
curve((19.83 * x)/(1514.84 + x), add = TRUE, 
      col = "salmon")
legend("topleft", legend = c("morning", "afternoon"), 
       pch = 19,
       col = c("cornflowerblue", "salmon"))

Assessing if the fitted curves are different means comparing the KI and GPPmax values. We can do that by using the time variable as an interaction term. For this we use the gnls() function from the {nlme} package that comes installed with R. In the params argument we state that we want to compare the “gpp_max” and “KI” coefficients by “time”. The summary output shows two coefficients with “timeafternoon” appended. These are the differences in the coefficients.

The coefficient of 0.568 is the difference in GPPmax values between morning and afternoon. This coefficient has a large standard error (8.461) and hence a small test statistic (0.568 / 8.461 = 0.067). Therefore the p-value is quite large and we conclude we don’t have enough evidence to declare the GPPmax for afternoon larger than the one for morning. The same conclusion is drawn for the KI coefficient as well.

library(nlme)
fit_both <- gnls(gpp ~ SSmicmen(par, gpp_max, KI), 
              data = d, 
              params = list(gpp_max + KI ~ time),
              start = c(19.5, 0.6, 1000, 1000))
summary(fit_both)
## Generalized nonlinear least squares fit
##   Model: gpp ~ SSmicmen(par, gpp_max, KI) 
##   Data: d 
##        AIC      BIC    logLik
##   69.00377 73.45563 -29.50188
## 
## Coefficients:
##                          Value Std.Error  t-value p-value
## gpp_max.(Intercept)    19.2625    3.1478 6.119346  0.0000
## gpp_max.timeafternoon   0.5689    8.4610 0.067236  0.9473
## KI.(Intercept)        573.7807  227.0225 2.527418  0.0242
## KI.timeafternoon      941.0561 1091.9500 0.861812  0.4033
## 
##  Correlation: 
##                       g_.(I) gpp_m. KI.(I)
## gpp_max.timeafternoon -0.372              
## KI.(Intercept)         0.962 -0.358       
## KI.timeafternoon      -0.200  0.972 -0.208
## 
## Standardized residuals:
##         Min          Q1         Med          Q3         Max 
## -1.11499272 -0.46417862 -0.12933482  0.08436811  2.92157204 
## 
## Residual standard error: 1.412996 
## Degrees of freedom: 18 total; 14 residual

Start values are required for this model. The first and third are for the intercepts, which in this case are GPPmax and KI values for the morning group. I basically used a value in between the values observed in the individual models above. The second and fourth are the differences. I eyeballed the model summaries above and estimated a difference in coefficients. For example, 19.8 - 19.2 is about 0.6.

References