View source: R/fit_metabolism.R
fit_metabolism | R Documentation |
Passes data and model parameters to streamMetabolizer
or
BASE
according to arguments passed to prep_metabolism.
NOTE: support for modeling with
BASE
is currently in development. Please use streamMetabolizer
in the meantime.
fit_metabolism(
d,
pool_K600 = "binned",
err_obs_iid = TRUE,
err_proc_acor = FALSE,
err_proc_iid = TRUE,
ode_method = "trapezoid",
deficit_src = "DO_mod",
skip_prompts = FALSE
)
d |
the output of prep_metabolism. |
pool_K600 |
character. Should the model pool information among
days to get more consistent daily estimates for K600? Options (see Details
section of
|
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_acor |
logical. Should autocorrelated process error (with the autocorrelation term phi fitted) be included? |
err_proc_iid |
logical. Should IID process error be included? |
ode_method |
character. The method to use in solving the ordinary differential equation for DO. Options:
|
deficit_src |
character. From what DO estimate (observed or modeled) should the DO deficit be computed? Options:
|
skip_prompts |
logical. If TRUE, you will not be prompted with questions
about sending your model results to the StreamPULSE server. Prompting occurs in the event
that your model outperforms the current best model stored by StreamPULSE for the
site and year modeled. When |
This function is a wrapper for streamMetabolizer
's model specification,
(mm_name, specs
) fitting (metab
), and prediction
(predict_metab
) functions, and all parameters except for d
are streamMetabolizer
parameters.
Default arguments passed to this function
specify the recommended starting point for fitting a metabolism model to
data from a typical stream or river. In addition to the parameters
documented here, this function calculates K600_lnQ_nodes_centers
(parameter of streamMetabolizer
's specs
function) as
a sequence of length 7 from
the minimum to the maximum natural log of daily discharge.
To access the full model specification interface of streamMetabolizer
,
please call its corresponding functions
(mm_name, specs, metab, predict_metab
) directly.
See the example section below for more.
returns a list containing the output of streamMetabolizer
's
metab
function (the model fit object), the output of
streamMetabolizer
's
predict_metab
function (metabolism predictions), and additional
information about model performance and specifications.
Mike Vlah, vlahm13@gmail.com
Aaron Berdanier
request_data
for acquiring StreamPULSE data;
prep_metabolism
for organizing data and acquiring additional
variables.
query_available_data(region='all')
streampulse_data = request_data(sitecode='NC_Eno',
startdate='2016-06-10', enddate='2016-10-23')
fitdata = prep_metabolism(d=streampulse_data, type='bayes',
model='streamMetabolizer', interval='15 min',
rm_flagged=list('Bad Data', 'Questionable'), fillgaps=fillgaps,
zq_curve=list(sensor_height=NULL, Z=Z_data, Q=Q_data,
fit='power', plot=TRUE), estimate_areal_depth=TRUE)
## fit model with default parameters
modelfit = fit_metabolism(fitdata)
## fit model with custom parameters
class(fitdata) = 'data.frame' #just a formality, execute and disregard
modname = mm_name(type='bayes', pool_K600='binned',
err_obs_iid=TRUE, err_proc_acor=FALSE, err_proc_iid=TRUE,
ode_method = 'trapezoid', deficit_src='DO_mod', engine='stan')
modspecs = specs(modname)
#overwrite default ln(Q) node centers
addis = tapply(log(fitdata$discharge), substr(fitdata$solar.time,1,10), mean)
modspecs$K600_lnQ_nodes_centers = seq(from=min(addis),
to=max(addis), length.out=7)
modelfit = metab(specs=modspecs, data=fitdata)
predictions = predict_metab(modelfit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.