games (version 1.0-1)

predProbs: User-friendly predicted probability analysis

Description

Easy generation and plotting of predicted probabilities from a fitted strategic model.

Usage

predProbs(model, x, xlim=c(min(x), max(x)), n=100, ci=0.95, makePlots=FALSE,
    report=TRUE, ...)

Arguments

model
a fitted model of class game.
x
character string giving the name of the variable to place "on the x-axis" while all others are held constant. Partial matches are accepted.
xlim
numeric, length 2: the range that x should be varied over (if x is continuous). Defaults to the observed range of x.
n
integer: the number of observations to generate (if x is continuous).
ci
numeric: width of the confidence interval to estimate around each predicted probability. Set to 0 to estimate no confidence intervals.
makePlots
logical: whether to automatically make the default plot for the returned object. See plot.predProbs.
report
logical: whether to print a status bar while obtaining the confidence intervals for the predicted probabilities.
...
used to set values for variables other than x in the profile of observations. See "Details" and "Examples".

Value

  • An object of class predProbs. This is a data frame containing each hypothetical observation's predicted probability, the upper and lower bounds of the confidence interval, and the value of each regressor.

Details

predProbs provides an easy way to analyze the estimated marginal effect of an independent variable on the probability of particular outcomes, using the estimates returned by a strategic model. The procedure is designed so that, for a preliminary analysis, the user can simply specify the fitted model and the independent variable of interest, and quickly obtain plots of predicted probabilities. However, it is flexible enough to allow for finely tuned analysis as well.

The procedure works by varying x, the variable of interest, across its observed range (or one specified by the user in xlim) while holding all other independent variables in the model fixed. The profile created by default is as follows (the same defaults as in the sim function in the Zelig package):

  • numeric, non-binary variables are fixed at their means
  • orderedvariables are fixed at their medians
  • all others are fixed at their modes (seeMode)
However, it is possible to override these defaults for any or all variables. For example, to set a variable named polity to its lower quartile, call predProbs with the argument polity = quantile(polity, 0.25). To set a factor variable to a particular level, provide the name of the level as a character string (in quotes). (Also see the examples below.)

Confidence intervals for each predicted point are generated by bootstrap. If model has a non-null boot.matrix element (i.e., a bootstrap was performed with the model fitting), then these results are used to make the confidence intervals. Otherwise, a parametric bootstrap sample is generated by sampling from a multivariate normal distribution around the parameter estimates. In this case, a warning is issued.

For information on plotting the predicted probabilities, see plot.predProbs. The plots are made with base graphics. If you prefer to use an alternative graphics package, all the information necessary to make the plots is included in the data frame returned.

See Also

predict.game for somewhat more flexible (but fussier) generation of predicted probabilities.

Examples

Run this code
data(war1800)
f1 <- esc + war ~ s_wt_re1 + revis1 | 0 | regime1 | balanc + regime2
m1 <- egame12(f1, data = war1800, boot = 10)

pp1 <- predProbs(m1, x = "s_wt_re1", n = 5)
print(pp1)  ## the hypothetical observations and their predicted probs
plot(pp1, which = 2)  ## see ?plot.predProbs for more plot examples

## changing the profile used
pp2 <- predProbs(m1, x = "s_wt_re1", n = 5, revis1 = 1, balanc = 0.7)
pp3 <- predProbs(m1, x = "s_wt_re1", n = 5, regime1 = "dem")
pp4 <- predProbs(m1, x = "s_wt_re1", n = 5, balanc = median(balanc))

## variable names (other than x) must match exactly!
pp5 <- predProbs(m1, x = "s_wt_re1", bal = 0.7)  ## error will result

## x can be a factor too
pp6 <- predProbs(m1, x = "regime1")

## predProbs (despite the name) also provides predictions for the optimal
## offer in ultimatum models
data(data_ult)
f2 <- offer + accept ~ x1 + x2 + x3 + x4 + w1 + w2 | z1 + z2 + z3 + z4 + w1 + w2
m2 <- ultimatum(f2, data = data_ult, maxOffer = 15, boot = 10)
pp7 <- predProbs(m2, x = "w1", n = 5)
print(pp7)

op <- par(mfrow = c(2, 1))
plot(pp7)
par(op)

Run the code above in your browser using DataCamp Workspace