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 |
newdata |
data frame of covariates used to produce the predicted probabilities.
If this is left empty, the entire original data set is used.
When |
new.theta |
a data frame of alternative parameters for comparative statics.
When missing, the coefficients from the |
type |
whether to provide probabilities over actions
(default, returns |
na.action |
how to deal with |
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
|
... |
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. Whencomp = TRUE
the functionuniroot
is called to find a more precise solution to the equilibrium constraint problem.- tol
Numeric. When
comp = TRUE
, this is the tolerance used byuniroot
.
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 eithermodel
orpar
. 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
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))