Learn R Programming

games (version 1.1.2)

makeFormulas: Model formula construction

Description

Interactive prompt for constructing model formulas.

Usage

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)

Value

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

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

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.

See Also

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

Examples

Run this code
## 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)

Run the code above in your browser using DataLab