conditional_mean: Estimating conditional mean of a time series

View source: R/conditional_mean.R

conditional_meanR Documentation

Estimating conditional mean of a time series

Description

This function estimates the means of a time series conditional on a set of other times series via additive models.

Usage

conditional_mean(data, formula)

Arguments

data

a tibble containing all the time series which are uniquely identified by the corresponding Timestamp.

formula

A GAM formula. See formula.gam. The details of model specification are given under ‘Details’.

Details

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.

Value

The function returns an object of class "gam" as described in gamObject.

See Also

gam

Examples

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))

PuwasalaG/conduits documentation built on April 22, 2023, 3:40 p.m.