if (FALSE) {
library(phenology)
# Example
data_f_21 <- Tagloss_format(outLR, model="21")
# model fitted by Rivalan et al. 2005
par <- c(a0_2=-5.43E-2, a1_2=-103.52, a4_2=5.62E-4,
delta_1=3.2E-4)
pfixed <- c(a2_2=0, a3_2=0, a2_1=0, a3_1=0)
model_before <- "par['a0_1']=par['a0_2'];par['a1_1']=par['a1_2'];par['a4_1']=par['a4_2']"
o <- Tagloss_fit(data=data_f_21, fitted.parameters=par, fixed.parameters=pfixed,
model_before=model_before)
plot(o, t=1:1000, model="cumul")
plot(o, t=1:1000, model="1")
plot(o, t=1:1000, model="2", add=TRUE, col="red")
# Same data fitted with new model
par <- c(D1_1 = 100.15324837975547, A_1 = 5.9576927964120188,
B_1 = 8.769924225871069, B_2 = 8.2353860179664125)
pfixed <- c(D2D1_1 = 2568, D3D2_1 = 2568, D2D1_2 = 2568, D3D2_2 = 2568)
o_4p_p1p2 <- Tagloss_fit(data=data_f_21, fitted.parameters = par,
fixed.parameters = pfixed,
model_before = "par['C_1']=par['B_1'];
par['A_2']=par['A_1'];
par['C_2']=par['B_2'];
par['D1_2']=par['D1_1']", hessian=TRUE)
# Without the N20 the computing is much faster
data_f_21_fast <- subset(data_f_21, subset=(is.na(data_f_21$N20)))
par <- c('D1_2' = 49.78891736351531,
'D2D1_2' = 1059.3635769732305,
'D3D2_2' = 12.434313273804602,
'A_2' = 5.2238379144659683,
'B_2' = 8.0050044071275543,
'C_2' = 8.4317863609499675,
'D1_1' = 701.80273287212935,
'D2D1_1' = 0.010951749100596819,
'D3D2_1' = 3773.6290607434876,
'A_1' = 205.42435592344776,
'B_1' = 9.9598342503239863,
'C_1' = 6.7234868237164722)
o <- Tagloss_fit(data=data_f_21_fast, fitted.parameters=par, hessian = TRUE)
plot(o, model="1", col="red")
plot(o, model="2", col="blue", add=TRUE)
legend("topright", legend=c("2->1", "1->0"), lty=1, col=c("blue", "red"))
}
Run the code above in your browser using DataLab