predict.sigfit {sigInt}R Documentation

Predicted probabilities and comparative statics for signaling games

Description

This method uses a fitted model of class sigfit to compute predicted probabilities or comparative statics. Users can provide either new data or a new parameters to generate counterfactuals of interest.

Usage

## S3 method for class 'sigfit'
predict(
  object,
  newdata,
  new.theta,
  type = c("actions", "outcomes"),
  na.action = na.pass,
  control = list(),
  parallel = FALSE,
  ...
)

Arguments

object

a fitted model of class sigfit.

newdata

data frame of covariates used to produce the predicted probabilities. If this is left empty, the entire original data set is used. When newdata is specified, new.theta should be either missing (use the coefficients from the sigfit object) or a one row data frame. See "Details" for more information. As with other predict methods, variable names must match those used to fit the model.

new.theta

a data frame of alternative parameters for comparative statics. When missing, the coefficients from the object are used. When specified, each row should be a complete parameter vector. If new.theta is specified, then newdata must be a data frame with only one row. Unlike other predict methods, column names do not matter here. Instead, the columns must be the same order as the coefficients in object. See "Details" and "Examples" for more information.

type

whether to provide probabilities over actions (default, returns p_C, p_R, and p_F) or outcomes (returns SQ, CD, SF, and BD).

na.action

how to deal with NAs in newdata.

control

list of options describing the grid search method. See "Details" for more information

parallel

logical. Should the comparative statics be computed in parallel, requires the parallel package be installed. Parallelization is done using parSapply.

...

Additional arguments (not currently used)

Details

This function is used to consider comparative statics in the crisis signaling game. The model of interest is fit using sigint. How this function behaves largely depends on how newdata and new.theta are specified.

When both newdata and new.theta are missing, all equilibria for every observation used to fit the model are computed. These equilibria are then used to calculated either choice probabilities (default, type = "action") the distribution over outcomes (type = "outcomes").

When only newdata is specified, then all equilibria are computed using the data frame in newdata and the coefficients from object. This produces standard comparative statics with respect to observed covariates.

When newdata is specified and new.theta is a one row data frame, then all equilibria are computed using the data frame in newdata and the coefficients from new.theta.

When newdata is a one row data frame and new.theta is specified, then all equilibria are computed using the data frame in newdata and the coefficients from new.theta. This is a comparative static on changing a structural parameter in the model.

If new.theta has more than one row, then newdata must be specified as a data frame with only one row. Anything else returns an error.

Equilibria are computed using a line search method. The control argument allows for user control over this process. Users can specify a list with the following named elements

gridsize

Integer. The number of points considered in the line search (default, 1e4). More points makes it more likely that all equilibria are discovered, but can slow down the search.

comp

Logical. Should an equilibrium be computed when discovered? When comp = FALSE (default), the mean of the grid points surrounding the equilibrium is used as an approximate solution. When comp = TRUE the function uniroot is called to find a more precise solution to the equilibrium constraint problem.

tol

Numeric. When comp = TRUE, this is the tolerance used by uniroot

.

When dealing with a larger problem, such as computing all equilibria for every observation, it can be helpful to parallelize process. If the user has the (suggested) parallel package, then the option parallel = TRUE will use the function parSapply is used.

Value

An object of class sigProb containing three elements:

predicted

data frame of predicted probabilities. The first column of this data frame is called Row, which corresponds to the rows in either model or par. In the event of multiple equilibria, this column allows for mapping data and parameters to all computed equilibria.

model

data frame of covariates used to produce the predicted probabilities.

par

data frame of parameters used to produce the predicted probabilities.

See Also

plot.sigProb, generate.eq

Examples

data(sanctionsData)

f1 <- sq+cd+sf+bd ~ sqrt(senderecondep) + senderdemocracy + contig + ally -1|#SA
                    anticipatedsendercosts|#VA
                    sqrt(targetecondep) + anticipatedtargetcosts + contig + ally|#CB
                    sqrt(senderecondep) + senderdemocracy + lncaprat | #barWA
                    targetdemocracy + lncaprat| #barWB
                    senderdemocracy| #bara
                    -1#VB
## Using Nested-Pseudo Likelihood  with default first stage    
## Not run:              
fit1 <- sigint(f1, data=sanctionsData, npl.trace=TRUE)
p.out <- predict(fit2, parallel=TRUE) #fitted choice probabilites for all observations

## End(Not run)

## Outcome probabilities for first five using PL method
Phat <- list(PRhat=sanctionsData$PRhat, PFhat=sanctionsData$PFhat)
fit2 <- sigint(f1, data=sanctionsData, method="pl", phat=Phat)
p1 <- predict(fit2, newdata=sanctionsData[1:5,], type="outcome")

## comparative static on \bar{a}, compute more precise equilibria with uniroot
new.theta <- data.frame(t(replicate(25, coef(fit2))))
new.theta[,19] <- seq(-6, 0, length=25)
p2 <- predict(fit2, newdata=sanctionsData[1,], new.theta=new.theta, control=list(comp=TRUE))



[Package sigInt version 0.2.0 Index]