View source: R/conditional_mean.R
conditional_mean | R Documentation |
This function estimates the means of a time series conditional on a set of other times series via additive models.
conditional_mean(data, formula)
data |
a tibble containing all the time series which are uniquely identified by the corresponding Timestamp. |
formula |
A GAM formula. See |
Suppose $x_t$ is a time series where its
mean is a function of $z_t$. i.e. $E(x_t|z_t) = m_x(z_t)$.
Then $m_x(z_t)$ can be estimated via generalised
additive models (GAM). This function uses
GAMs implemented in mgcv
package to estimate
the conditional means of a time series given a set of
time series predictors.
The function returns an object of class
"gam" as described in gamObject
.
gam
data <- NEON_PRIN_5min_cleaned |>
dplyr::filter(site == "upstream") |>
dplyr::select(Timestamp, turbidity, level, conductance, temperature)
fit_mean <- data |>
conditional_mean(turbidity ~ s(level, k = 8) +
s(conductance, k = 8) + s(temperature, k = 8))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.