% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rollshap.R
\name{roll_shap}
\alias{roll_shap}
\title{Rolling Shapley Values}
\usage{
roll_shap(x, y, width, weights = rep(1, width), intercept = TRUE,
  min_obs = width, complete_obs = TRUE, na_restore = FALSE,
  online = TRUE)
}
\arguments{
\item{x}{vector or matrix. Rows are observations and columns are the independent variables.}

\item{y}{vector or matrix. Rows are observations and columns are the dependent variables.}

\item{width}{integer. Window size.}

\item{weights}{vector. Weights for each observation within a window.}

\item{intercept}{logical. Either \code{TRUE} to include or \code{FALSE} to remove the intercept.}

\item{min_obs}{integer. Minimum number of observations required to have a value within a window,
otherwise result is \code{NA}.}

\item{complete_obs}{logical. If \code{TRUE} then rows containing any missing values are removed,
if \code{FALSE} then pairwise is used.}

\item{na_restore}{logical. Should missing values be restored?}

\item{online}{logical. Process observations using an online algorithm.}
}
\value{
An object of the same class and dimension as \code{x} with the rolling and expanding
Shapley values.
}
\description{
A function for computing the rolling and expanding Shapley values of time-series data.
}
\examples{
n <- 15
m <- 3
x <- matrix(rnorm(n * m), nrow = n, ncol = m)
y <- rnorm(n)
weights <- 0.9 ^ (n:1)

# rolling Shapley values with complete windows
roll_shap(x, y, width = 5)

# rolling Shapley values with partial windows
roll_shap(x, y, width = 5, min_obs = 1)

# expanding Shapley values with partial windows
roll_shap(x, y, width = n, min_obs = 1)

# expanding Shapley values with partial windows and weights
roll_shap(x, y, width = n, min_obs = 1, weights = weights)
}
