The package provides self starting models to fit Platt's model for a Photosynthesis-Irradiance (PI) curve. The platt0 model fits a Platt's original model

[ P = P_{max} (1 - \exp(-\alpha I/P_{max})) \exp(-\beta I/P_{max}) ] while platt fits a modified form of the model that includes an additional intercept [ P = P_{max} (1 - \exp(-\alpha I/P_{max})) \exp(-\beta I/P_{max}) + R ]

PI Example

The PI data set contains data for 6 Photosynthesis-Irrandaiance relationships

library(Platt)
data(PI)
head(PI)
library(ggplot2)
ggplot(PI,aes(x=I,y=P,group=Depth))+
  geom_point()+
  facet_wrap(~Depth)

Individual Sample

Extract the data for just depth C

PI.C <- subset(PI,Depth=="C")

To fit the modified model to just this data

fit <- nls(P~SSPlatt(I,alpha,beta,Pmax,R),data=PI.C)
summary(fit)

Fitted values can be extracted with fitted

fitted(fit)

and predictions can be made for new points with predict

PI.pr <- data.frame(I=seq(0,1700,20))
PI.pr$P <- predict(fit,PI.pr)
head(PI.pr)

The respiration corrected (P_{max}) is computed with correctedPmax

with(as.list(coef(fit)),
  correctedPmax(alpha,beta,Pmax))

These can be used to compare the data and fitted model

library(ggplot2)
ggplot(PI.C,aes(x=I,y=P))+
  geom_line(data=PI.pr,col="dodgerblue")+
  geom_point()+
  geom_point(aes(x=I,y=fitted(fit)),col="dodgerblue")

Plotting the residuals versus the fitted values suggests the variance might grow with the fitted mean.

plot(residuals(fit)~fitted(fit))

Batch Fitting

Summaries can be produced for all depths simultaneously with by

by(PI,PI$Depth,function(d) summary(nls(P~SSPlatt(I,alpha,beta,Pmax,R),data=d)))

Alternately, a table of the estimated coefficients can be constructed with dplyr

library(dplyr)
PI.coef <- PI %>% 
  group_by(Depth) %>% 
  do(as.data.frame(t(coef(nls(P~SSPlatt(I,alpha,beta,Pmax,R),data=.))))) %>%
  as.data.frame

PI.coef

Similarly, the fits can be graphically examined

library(dplyr)
PI.pr <- PI %>% 
  group_by(Depth) %>% 
  do({
    d <- data.frame(I=seq(0,1700,20))
    d$P <- predict(nls(P~SSPlatt(I,alpha,beta,Pmax,R),data=.),d)
    d
  })
ggplot(PI,aes(x=I,y=P,group=Depth))+
  geom_line(data=PI.pr)+
  geom_point()+
  facet_wrap(~Depth)


SWotherspoon/Platt documentation built on July 29, 2022, 11:34 a.m.