unnormalize | R Documentation |
This function produces an unnormalized series using conditional moments.
unnormalize(data, ystar, fit_mean, fit_var)
data |
a tsibble containing all the time series which are uniquely identified by the corresponding Timestamp. |
ystar |
The normalized variable name |
fit_mean |
Model object of class "conditional_moment" returned from
|
fit_var |
Model object of class "conditional_moment" returned from
|
A tsibble
with the conditional normliased series
data <- NEON_PRIN_5min_cleaned |>
dplyr::filter(site == "upstream") |>
dplyr::select(Timestamp, turbidity, level, conductance, temperature) |>
tsibble::as_tsibble(index = Timestamp)
fit_mean <- data |>
conditional_mean(turbidity ~ s(level, k = 8) +
s(conductance, k = 8) + s(temperature, k = 8))
fit_var <- data |>
conditional_var(
turbidity ~ s(level, k = 7) + s(conductance, k = 7) + s(temperature, k = 7),
family = "Gamma",
fit_mean = fit_mean
)
new_ts <- data |>
dplyr::mutate(ystar = normalize(data, turbidity, fit_mean, fit_var))
# For demonstrative purposes, declare three data points
# as missing values.
new_ts[3:5, 6] <- NA
## Not run:
library(fable)
library(dplyr)
impute_ts <- new_ts |>
model(ARIMA(ystar)) |>
interpolate(new_ts) |>
rename(y_star_impt = ystar) |>
full_join(new_ts, by = "Timestamp")
impute_ts <- impute_ts
mutate(y = unnormalize(impute_ts, y_star_impt, fit_mean, fit_var))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.