mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-05-18 21:21:22 +00:00
Merge pull request #8 from davharris/dots
pass arguments from prophet() to Stan
This commit is contained in:
commit
00a02b07b4
3 changed files with 16 additions and 5 deletions
|
|
@ -51,6 +51,7 @@ globalVariables(c(
|
|||
#' @param uncertainty.samples Number of simulated draws used to estimate
|
||||
#' uncertainty intervals.
|
||||
#' @param fit Boolean, if FALSE the model is initialized but not fit.
|
||||
#' @param ... Additional arguments, passed to \code{\link{fit.prophet}}
|
||||
#'
|
||||
#' @return A prophet model.
|
||||
#'
|
||||
|
|
@ -77,7 +78,8 @@ prophet <- function(df = df,
|
|||
mcmc.samples = 0,
|
||||
interval.width = 0.80,
|
||||
uncertainty.samples = 1000,
|
||||
fit = TRUE
|
||||
fit = TRUE,
|
||||
...
|
||||
) {
|
||||
# fb-block 1
|
||||
|
||||
|
|
@ -108,7 +110,7 @@ prophet <- function(df = df,
|
|||
validate_inputs(m)
|
||||
class(m) <- append(class(m), "prophet")
|
||||
if (fit) {
|
||||
m <- fit.prophet(m, df)
|
||||
m <- fit.prophet(m, df, ...)
|
||||
}
|
||||
|
||||
# fb-block 2
|
||||
|
|
@ -452,9 +454,11 @@ logistic_growth_init <- function(df) {
|
|||
#'
|
||||
#' @param m Prophet object.
|
||||
#' @param df Data frame.
|
||||
#' @param ... Additional arguments passed to the \code{optimizing} or
|
||||
#' \code{sampling} functions in Stan.
|
||||
#'
|
||||
#' @export
|
||||
fit.prophet <- function(m, df) {
|
||||
fit.prophet <- function(m, df, ...) {
|
||||
history <- df %>%
|
||||
dplyr::filter(!is.na(y))
|
||||
|
||||
|
|
@ -506,7 +510,8 @@ fit.prophet <- function(m, df) {
|
|||
model,
|
||||
data = dat,
|
||||
init = stan_init,
|
||||
iter = m$mcmc.samples
|
||||
iter = m$mcmc.samples,
|
||||
...
|
||||
)
|
||||
m$params <- rstan::extract(stan.fit)
|
||||
n.iteration <- length(m$params$k)
|
||||
|
|
@ -516,7 +521,8 @@ fit.prophet <- function(m, df) {
|
|||
data = dat,
|
||||
init = stan_init,
|
||||
iter = 1e4,
|
||||
as_vector = FALSE
|
||||
as_vector = FALSE,
|
||||
...
|
||||
)
|
||||
m$params <- stan.fit$par
|
||||
n.iteration <- 1
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ fit.prophet(m, df)
|
|||
\item{m}{Prophet object.}
|
||||
|
||||
\item{df}{Data frame.}
|
||||
|
||||
\item{...}{Additional arguments passed to the \code{optimizing} or
|
||||
\code{sampling} functions in Stan.}
|
||||
}
|
||||
\description{
|
||||
Fit the prophet model.
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ which will include uncertainty in seasonality.}
|
|||
uncertainty intervals.}
|
||||
|
||||
\item{fit}{Boolean, if FALSE the model is initialized but not fit.}
|
||||
|
||||
\item{...}{Additional arguments, passed to \code{\link{fit.prophet}}}
|
||||
}
|
||||
\value{
|
||||
A prophet model.
|
||||
|
|
|
|||
Loading…
Reference in a new issue