# NOT RUN {
#a single fit
t <- c(0, 1/3, 2/3, 1)
C <- c(320, 341, 352, 359)
print(fit <- HMR.fit(t, C, 1, 0.3, "a"))
plot(C ~ t)
curve({fit$phi + fit$f0 * exp(-fit$kappa * x)/(-fit$kappa*0.3)},
from = 0, to = 1, add = TRUE)
#compare with fitting function from HMR package 0.3.1
gasfluxes:::.HMR.fit1(t, C,
1, 0.3, "a",
ngrid = 1000, LR.always = FALSE, FollowHMR = TRUE,
JPG = FALSE, PS = FALSE, PHMR = FALSE, npred = 500,
xtxt = "", ytxt = "", pcttxt = "",
MSE.zero = 10 * max(.Machine$double.eps, .Machine$double.neg.eps),
bracketing.tol = 1e-07, bracketing.maxiter = 1000)[2:4]
# }
# NOT RUN {
#a dataset of 1329 chamber N2O flux measurements
data(fluxMeas)
fluxMeas[, n := length(time), by=serie]
print(fluxMeas)
fluxes <- fluxMeas[n > 3, HMR.fit(time, C, A, V, serie), by=serie]
print(fluxes)
plot(f0.se ~ f0, data = fluxes)
#one very large f0.se value (and several infinite ones not shown in the plot)
fluxes[is.finite(f0.se),][which.max(f0.se),]
plot(C~time, data=fluxMeas[serie=="ID940",])
print(tmp <- fluxes[is.finite(f0.se),][which.max(f0.se),])
curve({tmp[, phi] + tmp[, f0] * exp(-tmp[, kappa] * x)/
(-tmp[, kappa]*fluxMeas[serie=="ID940", V[1]]/
fluxMeas[serie=="ID940",A[1]])},
from = 0, to = 1, add = TRUE)
plot(f0.se ~ f0, data = fluxes[f0.se < 1e4,], pch = 16)
boxplot(fluxes[f0.se < 1e4, sqrt(f0.se)])
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab