View source: R/create_calc_NLL.R
create_calc_NLL | R Documentation |
Produces a function that can be given to nlm(). K600.daily may be passed to that function within the p vector (for fitting K600.daily) or as an additional argument (for fixing it).
create_calc_NLL(
calc_DO,
par.names = environment(environment(calc_DO)$calc_dDOdt)$metab.needs,
err_obs_iid = FALSE,
err_proc_iid = FALSE
)
calc_DO |
a function as from |
par.names |
vector of names of parameters that can be expected in calls to the function created by this one (the calc_NLL function) |
err_obs_iid |
logical. Should IID observation error be included? If not, the model will be fit to the differences in successive DO measurements, rather than to the DO measurements themselves. |
err_proc_iid |
logical. Should IID process error be included? |
a function that will return a negative log likelihood of the data
given a set of metab.pars. metab.pars is the first argument of the returned
function; its names are defined in par.names
.
data <- data_metab('1','30')[seq(1,48,by=2),]
dDOdt <- create_calc_dDOdt(data, ode_method='trapezoid', GPP_fun='linlight',
ER_fun='constant', deficit_src='DO_mod')
DO <- create_calc_DO(dDOdt)
NLL <- create_calc_NLL(DO, err_obs_iid=TRUE)
NLL(metab.pars=c(GPP.daily=2, ER.daily=-2, K600.daily=25))
NLL(metab.pars=c(GPP.daily=2, ER.daily=-2, K600.daily=25), DO.mod.1=8)
NLL(metab.pars=c(GPP.daily=4, ER.daily=-7, K600.daily=15))
NLL2 <- create_calc_NLL(DO, par.names=c('GPP.daily','ER.daily'), err_obs_iid=TRUE)
NLL2(metab.pars=c(GPP.daily=2, ER.daily=-2), K600.daily=25)
NLL3 <- create_calc_NLL(DO,
par.names=c('GPP.daily','ER.daily','K600.daily','DO.mod.1'), err_obs_iid=TRUE)
NLL3(metab.pars=c(GPP.daily=2, ER.daily=-2, K600.daily=25, DO.mod.1=9))
nlm(NLL, p=c(GPP.daily=2, ER.daily=-2, K600.daily=25))
nlm(NLL2, p=c(GPP.daily=2, ER.daily=-2), K600.daily=31.265)
nlm(NLL3, p=c(GPP.daily=2, ER.daily=-2, K600.daily=25, DO.mod.1=9))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.