## DVD

### Description

The data contain information on a sample of 20,000 customers who received an "instant coupon." The value of the coupon was varied between \$1 and \$5 and randomly assigned to the selected customers.

Our interest is in estimating the effect of the coupon on purchase of a newly released DVD. We will also investigate the role of two additional variables: `purch` is a measure of frequency of purchase and `last` is a measure of the recency of the last purchase by a customer. These measures are often used in practice to predict response rates.

Customers who received the coupon and purchased the DVD are identified in the data by the variable `buy`. Because the variable we want to predict is binary (`buy` = `yes` if the customer purchased the DVD and `buy` = `no` if she did not), logistic regression is appropriate.

### Variables

* buy = `yes` if the customer purchased the DVD and `no` if she did not
* coupon = value of an "instant coupon" in dollars. the value varies between \$1 and \$5
* purch = number of purchases by the customer in the past year
* last = days since the last purchase by the customer

### Source

The dataset `dvd.rda` is available for download from <a href = "https://radiant-rstats.github.io/docs/examples/dvd.rda" target="_blank">GitHub</a>.

Next, we'll estimate a Neural Network with 8 nodes in the hidden layer and parameter decay of 0.5. The optimal values for these parameters can be established using a grid-search in, e.g., the `caret` package in R. The network plots below illustrates how inputs are connected to the nodes in the hidden layer and to the output node. Predicted probabilities are stored in `predict_ann`.

```{r fig.width=7, fig.height=6.5, dpi = 200}
result <- ann(dataset = "dvd_wrk", rvar = "buy", evar = c("coupon", "purch", "last", "rnd1", "rnd2", "rnd3", "rnd4", "rnd5"), lev = "yes", size = 8, decay = 0.05, seed = 1234, data_filter = "training == 1")
summary(result)
plot(result, plots = "net")
pred <- predict(result, pred_data = "dvd_wrk")
store(pred, data = "dvd_wrk", name = "predict_ann")
```