---
title: "Spending function overview"
output: rmarkdown::html_vignette
bibliography: gsDesign.bib
nocite: |
  @JTBook
vignette: >
  %\VignetteIndexEntry{Spending function overview}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include=FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  dev = "svg",
  fig.width = 7.2916667,
  fig.align = "center",
  out.width = "80%"
)
```

## Introduction

Spending functions are used to set boundaries for group sequential designs.
Using the spending function approach to design offers a natural way to
provide interim testing boundaries when unplanned interim analyses are added
or when the timing of an interim analysis changes. Many standard and
investigational spending functions are provided in the gsDesign package.
These offer a great deal of flexibility in setting up stopping boundaries
for a design.

Spending functions have three arguments and return an object of type `spendfn`.
The `summary()` function for `spendfn` objects provides a brief
textual summary of a spending function or boundary used for a design.
Normally a spending function will be passed to `gsDesign()` in the parameter
`sfu` for the upper bound and `sfl` for the lower bound to specify a
spending function family for a design.
In this case, the user does not need to know the calling sequence ---
only how to specify the parameter(s) for the spending function. The calling
sequence is useful when the user wishes to plot a spending function as
demonstrated below in examples. In addition to using supplied spending
functions, a user can write code for a spending function. See examples.

## Examples

See `spendingFunction()` for the input and output specification of
spending functions. It also contains two code examples showing how to
use an implemented spending function and create new spending functions.
For more detailed examples, see the
[spending functions](https://keaven.github.io/gsd-tech-manual/spendfn.html)
chapter in the gsDesign technical manual.

## References