Learn R Programming

pscl (version 0.5)

predict.ideal: oredicted orobabilities from an ideal object

Description

compute predicted probabilities from an ideal object. This predict method uses the posterior mean values of x and beta to make predictions.

Usage

## S3 method for class 'ideal':
predict(object,
                        cutoff=.5,
                        start=rownames(object$x)[1],
                        ...)

## S3 method for class 'predict.ideal': print(x,digits=2,...)

Arguments

object
an object of class ideal (produced by ideal) with item parameters (beta) stored.
cutoff
numeric, a value between 0 and 1, the threshold to be used for sepatating predicted probabilities into yea and nay votes.
start
of the recorded MCMC samples, the sample that should be used as the first iteration included in prediction calculations.
x
object of class predict.ideal
digits
number of digits in printed object
...
further arguments passed to or from other methods.

Value

  • An object of class predict.ideal, containing:
  • pred.probsthe calculated predicted probability for each legislator for each vote.
  • predictionthe calculated prediction (0 or 1) for each legislator for each vote.
  • correctfor each legislator for each vote, whether the prediction was correct.
  • legis.percentfor each legislator, the percent of votes correctly predicted.
  • vote.percentfor each vote, the percent correctly predicted.
  • yea.percentthe percent of yea votes correctly predicted.
  • nay.percentthe percent of nay votes correctly predicted.
  • party.percentthe average value of the percent correctly predicted by legislator, separated by party, if party information exists in the rollcall object used for ideal. If no party information is available, party.percent = NULL.
  • overall.percentthe total percent of votes correctly predicted.
  • idealthe name of the ideal object, which can be later evaluated
  • descstring, the descriptive text from the rollcall object passed to ideal

Details

Predicted probabilities are computed using the mean of the posterior density of of $$x$$ (ideal points, or latent ability) and $$beta$$ (bill or item parameters). The percentage correctly predicted are determined by counting the percentages of votes with predicted probabilities of a Yea vote greater than or equal to the cutoff as the threshold.

See Also

ideal, summary.ideal, plot.predict.ideal

Examples

Run this code
data(s109)

id1 <- ideal(s109, meanzero=TRUE,
             store.item=TRUE)      ## too long for examples

id1 <- ideal(s109,
             d=1,
             meanzero=TRUE,
             store.item=TRUE,  ## need this to be TRUE for predict
             maxiter=1000,
             burnin=100,
             thin=10)  

phat <- predict(id1)
phat         ## print method

Run the code above in your browser using DataLab