From 58fa0bcec57f60ee3a71a550976f63166681bf93 Mon Sep 17 00:00:00 2001 From: bl Date: Fri, 28 Jul 2017 22:03:27 -0700 Subject: [PATCH] Suppress internal functions from reference manual --- R/R/prophet.R | 53 ++++++++++++++++++++++---- R/man/compile_stan_model.Rd | 1 + R/man/df_for_plotting.Rd | 1 + R/man/fourier_series.Rd | 1 + R/man/get_changepoint_matrix.Rd | 1 + R/man/get_prophet_stan_model.Rd | 1 + R/man/linear_growth_init.Rd | 1 + R/man/logistic_growth_init.Rd | 1 + R/man/make_all_seasonality_features.Rd | 1 + R/man/make_holiday_features.Rd | 1 + R/man/make_seasonality_features.Rd | 1 + R/man/parse_seasonality_args.Rd | 1 + R/man/piecewise_linear.Rd | 1 + R/man/piecewise_logistic.Rd | 1 + R/man/plot_holidays.Rd | 1 + R/man/plot_seasonality.Rd | 1 + R/man/plot_trend.Rd | 1 + R/man/plot_weekly.Rd | 1 + R/man/plot_yearly.Rd | 1 + R/man/predict_seasonal_components.Rd | 1 + R/man/predict_trend.Rd | 1 + R/man/predict_uncertainty.Rd | 1 + R/man/sample_model.Rd | 1 + R/man/sample_posterior_predictive.Rd | 1 + R/man/sample_predictive_trend.Rd | 1 + R/man/set_auto_seasonalities.Rd | 1 + R/man/set_changepoints.Rd | 1 + R/man/set_date.Rd | 1 + R/man/setup_dataframe.Rd | 1 + R/man/time_diff.Rd | 1 + R/man/validate_inputs.Rd | 1 + 31 files changed, 75 insertions(+), 8 deletions(-) diff --git a/R/R/prophet.R b/R/R/prophet.R index c77dbf6..d68afa6 100644 --- a/R/R/prophet.R +++ b/R/R/prophet.R @@ -133,6 +133,7 @@ prophet <- function(df = NULL, #' #' @param m Prophet object. #' +#' @keywords internal validate_inputs <- function(m) { if (!(m$growth %in% c('linear', 'logistic'))) { stop("Parameter 'growth' should be 'linear' or 'logistic'.") @@ -176,6 +177,8 @@ validate_inputs <- function(m) { #' trend. #' #' @return Stan model. +#' +#' @keywords internal get_prophet_stan_model <- function(model) { fn <- paste('prophet', model, 'growth.RData', sep = '_') ## If the cached model doesn't work, just compile a new one. @@ -201,6 +204,8 @@ get_prophet_stan_model <- function(model) { #' trend. #' #' @return Stan model. +#' +#' @keywords internal compile_stan_model <- function(model) { fn <- paste('stan/prophet', model, 'growth.stan', sep = '_') @@ -212,14 +217,15 @@ compile_stan_model <- function(model) { } #' Convert date vector -#' +#' #' Convert the date to POSIXct object -#' +#' #' @param ds Date vector, can be consisted of characters #' @param tz string time zone -#' +#' #' @return vector of POSIXct object converted from date -#' +#' +#' @keywords internal set_date <- function(ds = NULL, tz = "GMT") { if (length(ds) == 0) { return(NULL) @@ -238,15 +244,16 @@ set_date <- function(ds = NULL, tz = "GMT") { } #' Time difference between datetimes -#' +#' #' Compute time difference of two POSIXct objects -#' +#' #' @param ds1 POSIXct object #' @param ds2 POSIXct object #' @param units string units of difference, e.g. 'days' or 'secs'. -#' +#' #' @return numeric time difference -#' +#' +#' @keywords internal time_diff <- function(ds1, ds2, units = "days") { return(as.numeric(difftime(ds1, ds2, units = units))) } @@ -263,6 +270,7 @@ time_diff <- function(ds1, ds2, units = "days") { #' #' @return list with items 'df' and 'm'. #' +#' @keywords internal setup_dataframe <- function(m, df, initialize_scales = FALSE) { if (exists('y', where=df)) { df$y <- as.numeric(df$y) @@ -310,6 +318,7 @@ setup_dataframe <- function(m, df, initialize_scales = FALSE) { #' #' @return m with changepoints set. #' +#' @keywords internal set_changepoints <- function(m) { if (!is.null(m$changepoints)) { if (length(m$changepoints) > 0) { @@ -346,6 +355,7 @@ set_changepoints <- function(m) { #' #' @return array of indexes. #' +#' @keywords internal get_changepoint_matrix <- function(m) { A <- matrix(0, nrow(m$history), length(m$changepoints.t)) for (i in 1:length(m$changepoints.t)) { @@ -362,6 +372,7 @@ get_changepoint_matrix <- function(m) { #' #' @return Matrix with seasonality features. #' +#' @keywords internal fourier_series <- function(dates, period, series.order) { t <- time_diff(dates, set_date('1970-01-01 00:00:00')) features <- matrix(0, length(t), 2 * series.order) @@ -382,6 +393,7 @@ fourier_series <- function(dates, period, series.order) { #' #' @return Dataframe with seasonality. #' +#' @keywords internal make_seasonality_features <- function(dates, period, series.order, prefix) { features <- fourier_series(dates, period, series.order) colnames(features) <- paste(prefix, 1:ncol(features), sep = '_delim_') @@ -396,6 +408,7 @@ make_seasonality_features <- function(dates, period, series.order, prefix) { #' @return A dataframe with a column for each holiday. #' #' @importFrom dplyr "%>%" +#' @keywords internal make_holiday_features <- function(m, dates) { scale.ratio <- m$holidays.prior.scale / m$seasonality.prior.scale # Strip dates to be just days, for joining on holidays @@ -459,6 +472,7 @@ add_seasonality <- function(m, name, period, fourier.order) { #' #' @return Dataframe with seasonality. #' +#' @keywords internal make_all_seasonality_features <- function(m, df) { seasonal.features <- data.frame(zeros = rep(0, nrow(df))) for (name in names(m$seasonalities)) { @@ -487,6 +501,7 @@ make_all_seasonality_features <- function(m, df) { #' #' @return Number of Fourier components, or 0 for disabled. #' +#' @keywords internal parse_seasonality_args <- function(m, name, arg, auto.disable, default.order) { if (arg == 'auto') { fourier.order <- 0 @@ -521,6 +536,7 @@ parse_seasonality_args <- function(m, name, arg, auto.disable, default.order) { #' #' @return The prophet model with seasonalities set. #' +#' @keywords internal set_auto_seasonalities <- function(m) { first <- min(m$history$ds) last <- max(m$history$ds) @@ -562,6 +578,7 @@ set_auto_seasonalities <- function(m) { #' @return A vector (k, m) with the rate (k) and offset (m) of the linear #' growth function. #' +#' @keywords internal linear_growth_init <- function(df) { i0 <- which.min(df$ds) i1 <- which.max(df$ds) @@ -585,6 +602,7 @@ linear_growth_init <- function(df) { #' @return A vector (k, m) with the rate (k) and offset (m) of the logistic #' growth function. #' +#' @keywords internal logistic_growth_init <- function(df) { i0 <- which.min(df$ds) i1 <- which.max(df$ds) @@ -767,6 +785,7 @@ predict.prophet <- function(object, df = NULL, ...) { #' #' @return Vector y(t). #' +#' @keywords internal piecewise_linear <- function(t, deltas, k, m, changepoint.ts) { # Intercept changes gammas <- -changepoint.ts * deltas @@ -793,6 +812,7 @@ piecewise_linear <- function(t, deltas, k, m, changepoint.ts) { #' #' @return Vector y(t). #' +#' @keywords internal piecewise_logistic <- function(t, cap, deltas, k, m, changepoint.ts) { # Compute offset changes k.cum <- c(k, cumsum(deltas) + k) @@ -820,6 +840,7 @@ piecewise_logistic <- function(t, cap, deltas, k, m, changepoint.ts) { #' #' @return Vector with trend on prediction dates. #' +#' @keywords internal predict_trend <- function(model, df) { k <- mean(model$params$k, na.rm = TRUE) param.m <- mean(model$params$m, na.rm = TRUE) @@ -843,6 +864,7 @@ predict_trend <- function(model, df) { #' #' @return Dataframe with seasonal components. #' +#' @keywords internal predict_seasonal_components <- function(m, df) { seasonal.features <- make_all_seasonality_features(m, df) lower.p <- (1 - m$interval.width)/2 @@ -888,6 +910,7 @@ predict_seasonal_components <- function(m, df) { #' #' @return List with posterior predictive samples for each component. #' +#' @keywords internal sample_posterior_predictive <- function(m, df) { # Sample trend, seasonality, and yhat from the extrapolation model. n.iterations <- length(m$params$k) @@ -936,6 +959,7 @@ predictive_samples <- function(m, df) { #' #' @return Dataframe with uncertainty intervals. #' +#' @keywords internal predict_uncertainty <- function(m, df) { sim.values <- sample_posterior_predictive(m, df) # Add uncertainty estimates @@ -965,6 +989,7 @@ predict_uncertainty <- function(m, df) { #' #' @return List of trend, seasonality, and yhat, each a vector like df$t. #' +#' @keywords internal sample_model <- function(m, df, seasonal.features, iteration) { trend <- sample_predictive_trend(m, df, iteration) @@ -987,6 +1012,7 @@ sample_model <- function(m, df, seasonal.features, iteration) { #' #' @return Vector of simulated trend over df$t. #' +#' @keywords internal sample_predictive_trend <- function(model, df, iteration) { k <- model$params$k[iteration] param.m <- model$params$m[iteration] @@ -1073,6 +1099,7 @@ make_future_dataframe <- function(m, periods, freq = 'day', #' @param fcst Data frame returned by prophet predict. #' #' @importFrom dplyr "%>%" +#' @keywords internal df_for_plotting <- function(m, fcst) { # Make sure there is no y in fcst fcst$y <- NULL @@ -1198,6 +1225,8 @@ prophet_plot_components <- function( #' figure, if available. #' #' @return A ggplot2 plot. +#' +#' @keywords internal plot_trend <- function(df, uncertainty = TRUE, plot_cap = TRUE) { df.t <- df[!is.na(df$trend),] gg.trend <- ggplot2::ggplot(df.t, ggplot2::aes(x = ds, y = trend)) + @@ -1225,6 +1254,8 @@ plot_trend <- function(df, uncertainty = TRUE, plot_cap = TRUE) { #' @param uncertainty Boolean to plot uncertainty intervals. #' #' @return A ggplot2 plot. +#' +#' @keywords internal plot_holidays <- function(m, df, uncertainty = TRUE) { holiday.comps <- unique(m$holidays$holiday) %>% as.character() df.s <- data.frame(ds = df$ds, @@ -1258,6 +1289,8 @@ plot_holidays <- function(m, df, uncertainty = TRUE) { #' to Monday, and so on. #' #' @return A ggplot2 plot. +#' +#' @keywords internal plot_weekly <- function(m, uncertainty = TRUE, weekly_start = 0) { # Compute weekly seasonality for a Sun-Sat sequence of dates. df.w <- data.frame( @@ -1291,6 +1324,8 @@ plot_weekly <- function(m, uncertainty = TRUE, weekly_start = 0) { #' to Jan 2, and so on. #' #' @return A ggplot2 plot. +#' +#' @keywords internal plot_yearly <- function(m, uncertainty = TRUE, yearly_start = 0) { # Compute yearly seasonality for a Jan 1 - Dec 31 sequence of dates. df.y <- data.frame( @@ -1323,6 +1358,8 @@ plot_yearly <- function(m, uncertainty = TRUE, yearly_start = 0) { #' @param uncertainty Boolean to plot uncertainty intervals. #' #' @return A ggplot2 plot. +#' +#' @keywords internal plot_seasonality <- function(m, name, uncertainty = TRUE) { # Compute seasonality from Jan 1 through a single period. start <- set_date('2017-01-01') diff --git a/R/man/compile_stan_model.Rd b/R/man/compile_stan_model.Rd index fca4f98..a385c05 100644 --- a/R/man/compile_stan_model.Rd +++ b/R/man/compile_stan_model.Rd @@ -16,3 +16,4 @@ Stan model. \description{ Compile Stan model } +\keyword{internal} diff --git a/R/man/df_for_plotting.Rd b/R/man/df_for_plotting.Rd index 772709c..f8d630d 100644 --- a/R/man/df_for_plotting.Rd +++ b/R/man/df_for_plotting.Rd @@ -14,3 +14,4 @@ df_for_plotting(m, fcst) \description{ Merge history and forecast for plotting. } +\keyword{internal} diff --git a/R/man/fourier_series.Rd b/R/man/fourier_series.Rd index 546bce6..cef441e 100644 --- a/R/man/fourier_series.Rd +++ b/R/man/fourier_series.Rd @@ -19,3 +19,4 @@ Matrix with seasonality features. \description{ Provides Fourier series components with the specified frequency and order. } +\keyword{internal} diff --git a/R/man/get_changepoint_matrix.Rd b/R/man/get_changepoint_matrix.Rd index 7d52d99..08e87e1 100644 --- a/R/man/get_changepoint_matrix.Rd +++ b/R/man/get_changepoint_matrix.Rd @@ -15,3 +15,4 @@ array of indexes. \description{ Gets changepoint matrix for history dataframe. } +\keyword{internal} diff --git a/R/man/get_prophet_stan_model.Rd b/R/man/get_prophet_stan_model.Rd index 0b61230..243ad2d 100644 --- a/R/man/get_prophet_stan_model.Rd +++ b/R/man/get_prophet_stan_model.Rd @@ -16,3 +16,4 @@ Stan model. \description{ Load compiled Stan model } +\keyword{internal} diff --git a/R/man/linear_growth_init.Rd b/R/man/linear_growth_init.Rd index 02a413a..83815ad 100644 --- a/R/man/linear_growth_init.Rd +++ b/R/man/linear_growth_init.Rd @@ -19,3 +19,4 @@ Provides a strong initialization for linear growth by calculating the growth and offset parameters that pass the function through the first and last points in the time series. } +\keyword{internal} diff --git a/R/man/logistic_growth_init.Rd b/R/man/logistic_growth_init.Rd index 5fa65a6..86953ff 100644 --- a/R/man/logistic_growth_init.Rd +++ b/R/man/logistic_growth_init.Rd @@ -19,3 +19,4 @@ Provides a strong initialization for logistic growth by calculating the growth and offset parameters that pass the function through the first and last points in the time series. } +\keyword{internal} diff --git a/R/man/make_all_seasonality_features.Rd b/R/man/make_all_seasonality_features.Rd index cfd81d7..45eac31 100644 --- a/R/man/make_all_seasonality_features.Rd +++ b/R/man/make_all_seasonality_features.Rd @@ -17,3 +17,4 @@ Dataframe with seasonality. \description{ Dataframe with seasonality features. } +\keyword{internal} diff --git a/R/man/make_holiday_features.Rd b/R/man/make_holiday_features.Rd index 18688c9..7a46b6b 100644 --- a/R/man/make_holiday_features.Rd +++ b/R/man/make_holiday_features.Rd @@ -17,3 +17,4 @@ A dataframe with a column for each holiday. \description{ Construct a matrix of holiday features. } +\keyword{internal} diff --git a/R/man/make_seasonality_features.Rd b/R/man/make_seasonality_features.Rd index 28aba00..ae37706 100644 --- a/R/man/make_seasonality_features.Rd +++ b/R/man/make_seasonality_features.Rd @@ -21,3 +21,4 @@ Dataframe with seasonality. \description{ Data frame with seasonality features. } +\keyword{internal} diff --git a/R/man/parse_seasonality_args.Rd b/R/man/parse_seasonality_args.Rd index 9a5f0a0..6e8079e 100644 --- a/R/man/parse_seasonality_args.Rd +++ b/R/man/parse_seasonality_args.Rd @@ -24,3 +24,4 @@ Number of Fourier components, or 0 for disabled. \description{ Get number of Fourier components for built-in seasonalities. } +\keyword{internal} diff --git a/R/man/piecewise_linear.Rd b/R/man/piecewise_linear.Rd index c9c4d08..6fb862d 100644 --- a/R/man/piecewise_linear.Rd +++ b/R/man/piecewise_linear.Rd @@ -23,3 +23,4 @@ Vector y(t). \description{ Evaluate the piecewise linear function. } +\keyword{internal} diff --git a/R/man/piecewise_logistic.Rd b/R/man/piecewise_logistic.Rd index 0251ebd..577781e 100644 --- a/R/man/piecewise_logistic.Rd +++ b/R/man/piecewise_logistic.Rd @@ -25,3 +25,4 @@ Vector y(t). \description{ Evaluate the piecewise logistic function. } +\keyword{internal} diff --git a/R/man/plot_holidays.Rd b/R/man/plot_holidays.Rd index 93de11b..be6ac71 100644 --- a/R/man/plot_holidays.Rd +++ b/R/man/plot_holidays.Rd @@ -19,3 +19,4 @@ A ggplot2 plot. \description{ Plot the holidays component of the forecast. } +\keyword{internal} diff --git a/R/man/plot_seasonality.Rd b/R/man/plot_seasonality.Rd index 0e4a22d..a92e8b5 100644 --- a/R/man/plot_seasonality.Rd +++ b/R/man/plot_seasonality.Rd @@ -19,3 +19,4 @@ A ggplot2 plot. \description{ Plot a custom seasonal component. } +\keyword{internal} diff --git a/R/man/plot_trend.Rd b/R/man/plot_trend.Rd index f837baa..f3e9d65 100644 --- a/R/man/plot_trend.Rd +++ b/R/man/plot_trend.Rd @@ -20,3 +20,4 @@ A ggplot2 plot. \description{ Plot the prophet trend. } +\keyword{internal} diff --git a/R/man/plot_weekly.Rd b/R/man/plot_weekly.Rd index ba6e3a2..6476b56 100644 --- a/R/man/plot_weekly.Rd +++ b/R/man/plot_weekly.Rd @@ -21,3 +21,4 @@ A ggplot2 plot. \description{ Plot the weekly component of the forecast. } +\keyword{internal} diff --git a/R/man/plot_yearly.Rd b/R/man/plot_yearly.Rd index 4f7e3ea..9a7c534 100644 --- a/R/man/plot_yearly.Rd +++ b/R/man/plot_yearly.Rd @@ -21,3 +21,4 @@ A ggplot2 plot. \description{ Plot the yearly component of the forecast. } +\keyword{internal} diff --git a/R/man/predict_seasonal_components.Rd b/R/man/predict_seasonal_components.Rd index f28df7f..015961c 100644 --- a/R/man/predict_seasonal_components.Rd +++ b/R/man/predict_seasonal_components.Rd @@ -17,3 +17,4 @@ Dataframe with seasonal components. \description{ Predict seasonality broken down into components. } +\keyword{internal} diff --git a/R/man/predict_trend.Rd b/R/man/predict_trend.Rd index d668995..7bfb2b1 100644 --- a/R/man/predict_trend.Rd +++ b/R/man/predict_trend.Rd @@ -17,3 +17,4 @@ Vector with trend on prediction dates. \description{ Predict trend using the prophet model. } +\keyword{internal} diff --git a/R/man/predict_uncertainty.Rd b/R/man/predict_uncertainty.Rd index a6409c0..be65632 100644 --- a/R/man/predict_uncertainty.Rd +++ b/R/man/predict_uncertainty.Rd @@ -17,3 +17,4 @@ Dataframe with uncertainty intervals. \description{ Prophet uncertainty intervals. } +\keyword{internal} diff --git a/R/man/sample_model.Rd b/R/man/sample_model.Rd index 5aecfce..4757a09 100644 --- a/R/man/sample_model.Rd +++ b/R/man/sample_model.Rd @@ -21,3 +21,4 @@ List of trend, seasonality, and yhat, each a vector like df$t. \description{ Simulate observations from the extrapolated generative model. } +\keyword{internal} diff --git a/R/man/sample_posterior_predictive.Rd b/R/man/sample_posterior_predictive.Rd index 989eb2f..cf156b8 100644 --- a/R/man/sample_posterior_predictive.Rd +++ b/R/man/sample_posterior_predictive.Rd @@ -17,3 +17,4 @@ List with posterior predictive samples for each component. \description{ Prophet posterior predictive samples. } +\keyword{internal} diff --git a/R/man/sample_predictive_trend.Rd b/R/man/sample_predictive_trend.Rd index 8409059..6ccbc2b 100644 --- a/R/man/sample_predictive_trend.Rd +++ b/R/man/sample_predictive_trend.Rd @@ -19,3 +19,4 @@ Vector of simulated trend over df$t. \description{ Simulate the trend using the extrapolated generative model. } +\keyword{internal} diff --git a/R/man/set_auto_seasonalities.Rd b/R/man/set_auto_seasonalities.Rd index e0d1a13..9921fd5 100644 --- a/R/man/set_auto_seasonalities.Rd +++ b/R/man/set_auto_seasonalities.Rd @@ -19,3 +19,4 @@ spacing between dates in the history is <7 days. Turns on daily seasonality if there is >=2 days of history, and the spacing between dates in the history is <1 day. } +\keyword{internal} diff --git a/R/man/set_changepoints.Rd b/R/man/set_changepoints.Rd index 5cbea29..36b0f94 100644 --- a/R/man/set_changepoints.Rd +++ b/R/man/set_changepoints.Rd @@ -20,3 +20,4 @@ Sets m$changepoints to the dates of changepoints. Either: 2) We are generating a grid of them. 3) The user prefers no changepoints be used. } +\keyword{internal} diff --git a/R/man/set_date.Rd b/R/man/set_date.Rd index 8dad9ab..7402abe 100644 --- a/R/man/set_date.Rd +++ b/R/man/set_date.Rd @@ -17,3 +17,4 @@ vector of POSIXct object converted from date \description{ Convert the date to POSIXct object } +\keyword{internal} diff --git a/R/man/setup_dataframe.Rd b/R/man/setup_dataframe.Rd index 4486f4b..188ade5 100644 --- a/R/man/setup_dataframe.Rd +++ b/R/man/setup_dataframe.Rd @@ -21,3 +21,4 @@ Adds a time index and scales y. Creates auxillary columns 't', 't_ix', 'y_scaled', and 'cap_scaled'. These columns are used during both fitting and predicting. } +\keyword{internal} diff --git a/R/man/time_diff.Rd b/R/man/time_diff.Rd index 51bc220..8da0c49 100644 --- a/R/man/time_diff.Rd +++ b/R/man/time_diff.Rd @@ -19,3 +19,4 @@ numeric time difference \description{ Compute time difference of two POSIXct objects } +\keyword{internal} diff --git a/R/man/validate_inputs.Rd b/R/man/validate_inputs.Rd index 1f26fac..123e500 100644 --- a/R/man/validate_inputs.Rd +++ b/R/man/validate_inputs.Rd @@ -12,3 +12,4 @@ validate_inputs(m) \description{ Validates the inputs to Prophet. } +\keyword{internal}