metab_mle: Maximum likelihood metabolism model fitting function

View source: R/metab_mle.R

metab_mleR Documentation

Maximum likelihood metabolism model fitting function

Description

Uses maximum likelihood to fit a model to estimate GPP and ER from input data on DO, temperature, light, etc. Discharge is only used, if at all, to identify and exclude days with any negative discharge.

Usage

metab_mle(
  specs = specs(mm_name("mle")),
  data = mm_data(solar.time, DO.obs, DO.sat, depth, temp.water, light, discharge,
    optional = "discharge"),
  data_daily = mm_data(date, K600.daily, init.GPP.daily, init.Pmax, init.alpha,
    init.ER.daily, init.ER20, init.K600.daily, optional = "all"),
  info = NULL
)

Arguments

specs

a list of model specifications and parameters for a model. Although this may be specified manually (it's just a list), it is easier and safer to use specs to generate the list, because the set of required parameters and their defaults depends on the model given in the model_name argument to specs. The help file for specs lists the necessary parameters, describes them in detail, and gives default values.

data

data.frame (not a tbl_df) of input data at the temporal resolution of raw observations (unit-value). Columns must have the same names, units, and format as the default. The solar.time column must also have a timezone code ('tzone' attribute) of 'UTC'. See the 'Formatting data' section below for a full description.

data_daily

data.frame containing inputs with a daily timestep. See the 'Formatting data_daily' section below for a full description.

info

any information, in any format, that you would like to store within the metab_model object

Value

A metab_mle object containing the fitted model. This object can be inspected with the functions in the metab_model_interface. The code column in get_fit(mm) is defined in the Value subsection of ?nlm.

See Also

Other metab_model: metab_Kmodel, metab_bayes, metab_night, metab_sim

Examples

dat <- data_metab('3','30')
# PRK
mm <- metab_mle(data=dat)
predict_metab(mm)

# PR with fixed K on two days
dat_daily <- data.frame(date=as.Date(c("2012-09-18","2012-09-20")), K600.daily=35)
metab_mle(data=dat, data_daily=dat_daily)

# PRK with day-specific inits on some days
dat_daily <- data.frame(date=as.Date("2012-09-19"),
  init.GPP.daily=4, init.K600.daily=60)
metab_mle(data=dat, data_daily=dat_daily)

# Nonlinear GPP or ER equations
metab_mle(specs(mm_name('mle', GPP_fun='satlight')), data=dat)
metab_mle(specs(mm_name('mle', ER_fun='q10temp')), data=dat)
## Not run: 
plot_DO_preds(predict_DO(mm))

## End(Not run)

USGS-R/streamMetabolizer documentation built on Aug. 15, 2023, 7:50 a.m.