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