Description
The WeightedMovAvg function computes the weighted moving average of points in a time series, applying weights to older values. The weights for the older values decrease arithmetically.
Usage
td_weighted_mov_avg_mle ( data = NULL, target.columns = NULL, include.first = FALSE, window.size = 10, data.sequence.column = NULL, data.partition.column = NULL, data.order.column = NULL )
Arguments
data |
Required Argument. |
data.partition.column |
Required Argument. |
data.order.column |
Required Argument. |
target.columns |
Optional Argument. |
include.first |
Optional Argument. |
window.size |
Optional Argument. |
data.sequence.column |
Optional Argument. |
Value
Function returns an object of class "td_weighted_mov_avg_mle" which is a named list containing Teradata tbl object. Named list member can be referenced directly with the "$" operator using name: result.
Examples
# Get the current context/connection con <- td_get_context()$connection # Load example data. loadExampleData("weightedmovavg_example", "stock_vol") # Create remote tibble objects. stock_vol <- tbl(con, "stock_vol") # Example: Compute the simple moving average for columns: "stockprice" and "volume". # The input table, stock_vol, contains hypothetical stock price and volume data of three # companies between 17 May 1961 and 21 June 1961. # Note: This also includes the first 9 rows with moving average NA. td_weighted_mov_avg_out <- td_weighted_mov_avg_mle(data = stock_vol, data.partition.column = c("id"), data.order.column = c("name"), target.columns = c("stockprice","volume"), include.first = TRUE, window.size = 5 )