Exercise

# Typical values of data

Sometimes you want to make a very quick check of what the model output looks like for "typical" inputs. When you use `evaluate_model()`

without the `data`

argument, the function will use the data on which the model was trained to select some typical levels of the inputs. `evaluate_model()`

provides a tabular display of inputs and outputs.

Many people prefer a graphical display. The `fmodel()`

function works in the same way as `evaluate_model()`

, but displays the model graphically. When models have more than one input variable (the usual case) choices need to be made about which variable to display in what role in the graphic. For instance, if there is a quantitative input, it's natural to put that on the x-axis. Additional explanatory variables can be displayed as color or as *facets* (i.e. small subgraphs). You do not need to display all of the explanatory variables in the graph.

The syntax for `fmodel()`

is

```
fmodel(model_object, ~ x_var + color_var + facet_var)
```

where, of course, you'll use the name of the variable you want on the x-axis instead of `x_var`

and similarly for `color_var`

and `facet_var`

(which are optional). Only the right-hand side of the `~`

is used in the formula.

Instructions

**100 XP**

`AARP`

and `insurance_cost_model`

are available in your workspace.

- Use
`evaluate_model()`

to calculate the model output for typical values of the explanatory variables (i.e. do not specify the`data`

argument). - Construct an appropriate formula to use with
`fmodel()`

to reproduce the graphic shown in the display. - The plot shown is nice enough, but it doesn't serve all purposes. For instance, it's hard to see the differences in insurance costs between the sexes. Change the value of
`new_formula`

to try different arrangements of the terms in the formula until you get a plot that more clearly displays the difference between sexes.*Note that you can highlight the first few lines of code and run them with 'control + enter' before completing the entire script*.