% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fn_BaySIR.R
\name{BaySIR_predict}
\alias{BaySIR_predict}
\title{BaySIR posterior prediction}
\usage{
BaySIR_predict(
  T_pred = 10,
  MCMC_spls,
  B,
  I_D_0,
  N,
  confirmed_cases_cum = NULL,
  X_pred = NULL,
  Y_pred = NULL,
  X = NULL,
  Y = NULL,
  kappa = 1,
  link = 1
)
}
\arguments{
\item{T_pred}{The number of future days that you would like to predict. 
Will predict B[T + 1], ..., B[T + T_pred]. Default is 10 days.}

\item{MCMC_spls}{A list of the MCMC samples for the parameters obtained 
from \code{\link{BaySIR_MCMC}}.}

\item{B}{A length \code{T + 1} vector of daily new confirmed cases 
\code{B[0], ..., B[T]}. \code{B[t]} represents the increment in
confirmed cases between day \code{t} and day \code{t + 1}.}

\item{I_D_0}{The total number of confirmed cases on day 0.}

\item{N}{The population size.}

\item{confirmed_cases_cum}{Optional. A length \code{T + 2} vector of cumulative 
confirmed case counts. If \code{B} and \code{I_D_0} have already been 
specified, then \code{confirmed_cases_cum} will be ignored. If not both 
\code{B} and \code{I_D_0} are specified and \code{confirmed_cases_cum}
is supplied, then \code{confirmed_cases_cum}
will be used to calculate \code{B} and \code{I_D_0}.}

\item{X_pred}{Optional. A \code{T_pred * Q} matrix, covariates related to the disease 
transmission rate for future days \code{T + 1, ..., T + T_pred}. 
Default is an intercept term plus a time trend, 
\code{X_pred[t, ] = (1, T + t)}.}

\item{Y_pred}{Optional. A \code{T_pred * K} matrix, covariates related to the diagnosis 
ratefor future days \code{T + 1, ..., T + T_pred}. Default 
contains only an intercept term, \code{Y_pred[t, ] = 1}.}

\item{X}{Optional. A \code{(T + 1) * Q} matrix, covariates related to the disease 
transmission rate. Default is an intercept term plus a time trend, 
\code{X[t, ] = (1, t)}.}

\item{Y}{Optional. A \code{(T + 1) * K} matrix, covariates related to the diagnosis 
rate. Default is only an intercept term, \code{Y[t, ] = 1}.}

\item{link}{Optional. The link function to be used for the diagnosis rate (the rate 
is between 0 and 1, and the link function transforms it to the real line).
\code{1}, \code{2} and \code{3} represent the logit, probit and 
complementary log-log link, respectively. Default is \code{1}.}
}
\value{
A list of the following:
\describe{
\item{\code{pred_spls}}{Again, a list of samples for the parameters from their 
                        posterior predictive distributions.
\itemize{
  \item \code{B_pred_spls} A \code{T_pred * niter} matrix, samples of the 
                      B (case counts) for future days 
                      \code{T + 1, ..., T + T_pred} from its posterior predictive
                      distribution. Each column corresponds to a sample, and each
                      row corresponds to a day.
  \item \code{R_eff_pred_spls} A \code{T_pred * niter} matrix, samples of the 
                      effective reproduction number for future days 
                      \code{T + 1, ..., T + T_pred} from its posterior predictive
                      distribution. Each column corresponds to a sample, and each
                      row corresponds to a day.
  \item \code{THETA_pred_spls} Samples of a specific time-dependent parameter 
                      \code{THETA} from its posterior predictive distribution
                      for future days. 
                      Here, \code{THETA} can be \code{S}, \code{I_U},
                      \code{beta}, etc.
}}
\item{\code{pred_summary}}{Summaries for the posterior predictive distributions
                           of the parameters.
\itemize{
  \item \code{B} A \code{T_pred * 3} matrix, summaries for the posterior 
                 predictive distribution of B (case counts)
                 for future days 
                 \code{T + 1, ..., T + T_pred}. Columns 1, 2 and 3 correspond to
                 the posterior medians, 2.5% quantiles and 97.5% quantiles.
                 For example, to access the posterior median of B on day
                 \code{T + j}, use
                 \code{pred_summary$B[j, 1]}.
  \item \code{R_eff} A \code{T_pred * 3} matrix, summaries for the posterior 
                     predictive distribution of the 
                     effective reproduction number for future days 
                      \code{T + 1, ..., T + T_pred}. Columns 1, 2 and 3 correspond to
                     the posterior medians, 2.5% quantiles and 97.5% quantiles.
                     For example, to access the posterior median of R_eff on day
                     \code{T + j}, use
                     \code{pred_summary$R_eff[j, 1]}.
  \item \code{THETA} Summaries of a specific time-dependent parameter 
                     \code{THETA} from its posterior predictive distribution
                     for future days. 
                     Here, \code{THETA} can be \code{S}, \code{I_U},
                     \code{beta}, etc.
}}
}
}
\description{
Sampling from the posterior predictive distribution of future observations,
in particular, future case counts.
}
\examples{
library(BaySIR)
  
# read data
data(data_sim_1)
B = data_sim_1$B
I_D_0 = data_sim_1$I_D[1]
N = data_sim_1$N

# run MCMC (may take a few minutes, depending on computer. ~ 2 mins on Macbook Pro)
result_list = BaySIR_MCMC(B = B, I_D_0 = I_D_0, N = N)

# sample from posterior predictive distribution (for future 30 days)
predict_list = BaySIR_predict(T_pred = 30, MCMC_spls = result_list$MCMC_spls, B = B, I_D_0 = I_D_0, N = N)

# posterior median of future B's
predict_list$pred_summary$B[ , 1]

# posterior summary for the future effective reproduction numbers
predict_list$pred_summary$R_eff

# End(Not run)
}
