makeFormulas: Model formula construction

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/makeFormulas.r

Description

Interactive prompt for constructing model formulas.

Usage

1
makeFormulas(model, outcomes)

Arguments

model

name of the model (must be from the games package) for which to make a formula.

outcomes

character vector with descriptions of the possible outcomes of the game (see "Details" for a more precise explanation)

Details

All of the staistical models in the games package require the specification of multiple model formulas, as each player's utility is a function of potentially different regressors. The number of equations to specify ranges from two in ultimatum to eight in egame123. makeFormulas is an interactive tool to simplify the specification process.

To use makeFormulas, specify the model you want to fit (model) and descriptions of the outcomes of the game (outcomes). The order of the descriptions in outcomes should match the numbering in the game tree in the help page for model. For example, with egame122, the order is:

  1. Player 1 moves Left, Player 2 moves Left

  2. Player 1 moves Left, Player 2 moves Right

  3. Player 1 moves Right, Player 2 moves Left

  4. Player 1 moves Right, Player 2 moves Right

If the dependent variable in the dataset (dat) is a factor (y) whose levels contain the descriptions, then either outcomes = dat$y or outcomes = levels(dat$y) will work.

As an example, consider the following use of egame122. Player 1 is the legislature, which can propose budget cuts (left on the game tree) or increases (right). Player 2 is the president, who can sign or veto the legislature's budget proposal (left and right respectively). The variables of interest are the president's party (presparty), the legislature's party (legparty), and the year's percentage GDP growth (growth). To construct the formulas for this case, run makeFormulas(egame122, outcomes = c("budget cuts passed", "budget cuts vetoed", "budget increase passed", "budget increase vetoed")). The first set of options that appears is

1
2
3
4
5
6
Equation for player 1's utility from budget cuts passed:

1: fix to 0
2: intercept only
3: regressors, no intercept
4: regressors with intercept

To specify this utility as a function of a constant, the legislature's party, and GDP growth, select option 4 and enter legparty growth at the prompt. makeFormulas will then move on to ask about Player 1's utility for the other three outcomes, followed by Player 2's utility for the outcomes for which her utility is not fixed to 0 (see egame122). See "Examples" below for a full example of the input and constructed formula in this case.

It is not necessary to use makeFormulas to specify model formulas. See the help file of each model for examples of "manually" making the formula.

Value

An object of class "Formula", typically to be used as the formulas argument in a statistical model from the games package.

Author(s)

Brenton Kenkel (brenton.kenkel@gmail.com)

See Also

Formula (and the Formula package generally) for the details of how games deals with multiple model formulas.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
## Not run: 
R> f1 <- makeFormulas(egame122, outcomes = c("budget cuts passed",
"budget cuts vetoed", "budget increase passed", "budget increase vetoed"))

---
Equation for player 1's utility from budget cuts passed: 

1: fix to 0
2: intercept only
3: regressors, no intercept
4: regressors with intercept

Selection: 4

Enter variable names (separated by spaces):
legparty growth

---
Equation for player 1's utility from budget cuts vetoed: 

1: fix to 0
2: intercept only
3: regressors, no intercept
4: regressors with intercept

Selection: 2

---
Equation for player 1's utility from budget increase passed: 

1: fix to 0
2: intercept only
3: regressors, no intercept
4: regressors with intercept

Selection: 4

Enter variable names (separated by spaces):
legparty growth

---
Equation for player 1's utility from budget increase vetoed: 

1: fix to 0
2: regressors, no intercept

Selection: 1

---
Equation for player 2's utility from budget cuts vetoed: 

1: fix to 0
2: intercept only
3: regressors, no intercept
4: regressors with intercept

Selection: 4

Enter variable names (separated by spaces):
presparty growth

---
Equation for player 2's utility from budget increase vetoed: 

1: fix to 0
2: intercept only
3: regressors, no intercept
4: regressors with intercept

Selection: 4

Enter variable names (separated by spaces):
presparty growth

---
What is the name of the dependent variable in the dataset? (If stored as
action indicators/dummies, separate their names with spaces.)
budgincrease veto
R> f1
budgincrease + veto ~ legparty + growth | 1 | legparty + growth | 
    0 | presparty + growth | presparty + growth

## End(Not run)

games documentation built on May 2, 2019, 3:26 p.m.