# NOT RUN {
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, 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 <- structure(c(48.8292784204825, 1039.02842229274, -89.3162940697861,
5.21817463244988, 8.00575451188548, 8.32971268127933, 161.265553603601,
602.935748681661, 2643.57415102633, 16.752815732218, 10.181616195839,
7.14279063312016), .Names = c("D1_2", "D2D1_2", "D3D2_2", "A_2",
"B_2", "C_2", "D1_1", "D2D1_1", "D3D2_1", "A_1", "B_1", "C_1"))
o <- Tagloss_fit(data=data_f_21_fast, fitted.parameters=par)
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