panchtox
panchtox

Reputation: 642

How to obtain consistently sign direction using rollcall and ideal from pscl package?

I'm using functions ideal and rollcall from pscl package but the same voters receive alternatively negative sign values or positive sign values depending (at list) on the ordering of the dataset. As I'm calculating this for several periods, I need its behavior to be consistent for every year. Is there any way to control this aspect?

Upvotes: 0

Views: 63

Answers (1)

MDEWITT
MDEWITT

Reputation: 2368

Okey, so looking at the documentation it looks like you can use the priors argument to specify which legislator you want to be your negative anchor and which one to be the positive anchor. See https://cran.r-project.org/web/packages/pscl/pscl.pdf

Say for instance you know that legislator 1 is the most conservative and legislator 50 is the least conservative, you could make a matrix of means to use as priors. Based on the documentation anything you don't specify will use the default priors.

# 50 legislators
my_mean <- rep(0, 50)

my_mean[1] <- -3
my_mean[50] <- 3

Now when you go into the ideal function you can specify xp in the priors argument as below:

ideal(object, codes = object$codes,
dropList = list(codes = "notInLegis", lop = 0),
d = 1, maxiter = 10000, thin = 100, burnin = 5000,
impute = FALSE,
normalize = FALSE,
meanzero = normalize,
priors = list(xp = my_mean),  # Here, all defaults used for other args
startvals = "eigen",
store.item = FALSE, file = NULL,
verbose=FALSE, use.voter=NULL)

Without some data, I can't test it, but that should work. Additionally, instead of just fixing two persons you could have an ifelse statement and assign priors to a party:

my_mean <- ifelse(party == "Conservative", -3, 3)

Or something like this. I have an example of the above here, but it uses rstan.

Upvotes: 1

Related Questions