Tom Brunell
Professor of Political Science
Associate Dean of Graduate Education
School of Economic, Political and Policy Sciences
The University of Texas at Dallas
800 W. Campbell Road, GR 31
Richardson, TX 75080-3021
(972) 883-4963
http://www.utdallas.edu/~tbrunell
JudgeIt Folks,
While I am a JudgeIt veteran, I am definitely an R novice. I think I
got it to work on some recent election data, but the results are a bit
weird. Below I have pasted my code and some results. I have also
attached a seats votes curve for 2010. Eyeballing the graph would
lead me to believe there is a pro-Democratic bias of about 5%, but the
estimates for that year come in around 16 percent. 16 percent is very
high, so I don't think that is right. I assume I have made a mistake
here somewhere. Any advice would be greatly appreciated.
---------start code------------------
# House.R
# 20110804 : Initial version
rm(list = ls(all = TRUE))
library(JudgeIt)
nv10 <- read.csv(file="mpg11_EDLDNV10.csv", header=TRUE)
nv08 <- read.csv(file="mpg11_EDLDNV08.csv", header=TRUE)
nv06 <- read.csv(file="mpg11_EDLDNV06.csv", header=TRUE)
nv04 <- read.csv(file="mpg11_EDLDNV04.csv", header=TRUE)
nv02 <- read.csv(file="mpg11_EDLDNV02.csv", header=TRUE)
elections <- list("2002"=nv02, "2004"=nv04, "2006"=nv06, "2008"=nv08,
"2010"=nv10)
unc <- function(x) 1*(x>0.95)-1*(x<0.05)
judge.out <- judgeit(model.form=vote ~ inc +
unc
(vote
),vote
.formula=turnout~1,same.districts=T,use.last.votes=T,data=elections)
j.ob.10 <-bias.resp(judge.out,year=2010)
j.ob.10
seating <- seats(judge.out,mean.votes=seq(0.3,0.7,by=0.01),year=2010)
plot(seating)
______end code______
results for 2010
Mean
SD 2.5% 50% 97.5%
Partisan Bias (0.5) 0.1667088 0.02265697 0.11447372
0.1676165 0.2070548
Partisan Bias (0.45-0.55) 0.1429006 0.02012143 0.09972217
0.1444991 0.1807542
Responsiveness (0.45-0.55) 1.7342698 0.23440666 1.29864336 1.7258444
2.1483183
Responsiveness (observed) 1.0879783 0.23542207 0.71150988 1.0656005
1.5986896
Tom Brunell
Professor of Political Science
Associate Dean of Graduate Education
School of Economic, Political and Policy Sciences
The University of Texas at Dallas
800 W. Campbell Road, GR 31
Richardson, TX 75080-3021
(972) 883-4963
http://www.utdallas.edu/~tbrunell
--
JudgeIt mailing list served by Harvard-MIT Data Center
List Address: judgeit(a)lists.gking.harvard.edu
Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=judgeit
JudgeIt Information: http://gking.harvard.edu/judgeit
Hello, this is Diana, and I have few questions regarding JudgeIt.
I am trying to calculate responsiveness and partisan using state
election data,and wondering about the command for "uncontesteds". My
variables are almost same as built-in data,house 6311,which are State,
Chamber, District, Turnout, and vote.
My formula is
j.obpas<-judgeit(model.formula=vote~unc(vote),vote.formula=Turnout~1,uncontesteds="default",same.d=same.dists,data=pas,use.last.votes=T,weight="constant")
When I tried uncontesteds="default", it worked. However,
uncontesteds="impute" did not
work. Do you have any idea what I should do to make this work?
My second question is, I got an error message "Error in solve.default(mom) :
Lapack routine dgesv: system is exactly singular" when I tried to
create an object for
a specific state. What I am wondering is, most of the states worked well using
j.obpas<-judgeit(model.formula=vote~unc(vote),vote.formula=Turnout~1,uncontesteds="default",same.d=same.dists,data=pas,use.last.votes=T,weight="seats"), except two states. How can I fix
this
problem?
Any comment will be appreciated.
Thanks!!
Best,
Diana
--
JudgeIt mailing list served by Harvard-MIT Data Center
List Address: judgeit(a)lists.gking.harvard.edu
Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=judgeit
JudgeIt Information: http://gking.harvard.edu/judgeit
I Hope you get this on time, I'm sorry i didn't inform you about my trip to
the Nicosia for this really urgent program i had to attend.I'm presently in
the Nicosia south Cyprus now and am having some difficulties here because i
mugged and my wallet which i had all my money and bank cards in. I have
limited access to internet at the moment, So i'm using this slight
opportunity asking you to assist me with a loan of 1,500 Dollars to sort
out my hotel bills and to book a flight ticket back home.I have complained
to the police authorities here but they are not responding to the matter
effectively, I will appreciate whatever you can afford to assist me with
even if you don't have up to this amount. I'll Refund the money back to you
as soon as i return home. I don't have a phone where i can be reached, use
my details below to send the money by western union so that i can pick up
the funds from a western union outlet nearby.
Name: Eric McGhee
Location: Nicosia, South Cyprus
Amount: 1500 Dollars
Please email me the western union details and # mtcn by email so that i can
receive it and pick up without making a mistake, and please just do as i
have told you as i feel i can confide in you at this time hoping you will
not let me down.
Thanks
Eric McGhee
Hi!
I'm having the following problem when I try to install on my Vista
machine:
> install.packages("JudgeIt")
Warning in install.packages("JudgeIt") :
argument 'lib' is missing: using
'C:\Users\TWISTOR\Documents/R/win-library/2.9'
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.case.edu/bin/windows/contrib/2.9/JudgeIt_1.3.3.zip'
Content type 'application/zip' length 606527 bytes (592 Kb)
opened URL
downloaded 592 Kb
package 'JudgeIt' successfully unpacked and MD5 sums checked
The downloaded packages are in
C:\Users\TWISTOR\AppData\Local\Temp\RtmpRVHUrw\downloaded_packages
updating HTML package descriptions
Warning message:
In file.create(f.tg) :
cannot create file 'C:\PROGRA~1\R\R-29~1.0/doc/html/packages.html', reason
'Permission denied'
Any ideas??
Matthew E. Hogan
Research Assistant
University of Massachusetts Dartmouth
<mhogan1(a)umassd.edu>
A new, upgraded version of JudgeIt is now available on CRAN (as well as
gking.harvard.edu). It offers substantial improvements in usability with
more S3 methods, as well as some essential methodological corrections.
I recommend running the demo routine
demo(judgeit.primer)
to get a taste for all the functions of the package.
AT
Since my last question tanked, I will try it another way.
How about if I add a vector of the lagged vote before running anything
in R. What would the command look like? I need to add the lagged
vote to the model and tell it to not automatically used the lagged vote?
Tom Brunell
School of Economic Political and Policy Sciences
The University of Texas at Dallas
800 W. Campbell Road
Richardson, TX 75080
(972) 883-4963
http://www.utdallas.edu/~tbrunell
--
JudgeIt mailing list served by Harvard-MIT Data Center
List Address: judgeit(a)lists.gking.harvard.edu
Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=judgeit
JudgeIt Information: http://gking.harvard.edu/judgeit
On Fri, Jul 11, 2008 at 11:59 AM, Andrew C. Thomas <acthomas.ca(a)gmail.com>
wrote:
> Yeah, just add the new terms to the new.covariates list:
>
> new.covariates=list("inc",0,"sauce",sauce,"spending",new.spending)
>
> etc.
>
> AT
>
>
> On Thu, Jul 10, 2008 at 4:34 PM, Eric McGhee <emcghee73(a)gmail.com> wrote:
>
>> This solution worked well. One other question: is there a way to do a
>> counterfactual for two or more variables at once? For example, if I wanted
>> to simulate changing the partisan registration of the districts *and* the
>> campaign spending in each race. Is there a syntax for that?
>>
>> Eric
>>
>>
>> On Thu, Jul 10, 2008 at 9:05 AM, Eric McGhee <emcghee73(a)gmail.com> wrote:
>>
>>> Terrific--I'll give that a try. Thanks again for your help!
>>>
>>> Best,
>>> Eric
>>>
>>>
>>> On Thu, Jul 10, 2008 at 7:17 AM, Andrew C. Thomas <
>>> acthomas(a)fas.harvard.edu> wrote:
>>>
>>>> OK, I've got some answers:
>>>>
>>>> 1) When you run an analysis on an existing judgeit object, it doesn't
>>>> load the new characteristics into the object to be saved. At this time I'm
>>>> inclined to keep it this way so that different counterfactuals don't get
>>>> carried forward.
>>>>
>>>> 2) The problem seems to be the way R stores objects. You'd like the
>>>> vector stored in
>>>>
>>>> regdf90s[[8]]
>>>>
>>>> but it registers this as a data frame with length 1, not 80. With the
>>>> fix
>>>> judgeit(routine= "svsum", judgeit.object=judg.obj,
>>>> year=which(years==2006), new.covariates=list("regdf",regdf90s[[8]][,1]))
>>>>
>>>> it reads it as a vector of length 80, and this one works on my machine.
>>>> I'll have to think about this issue before "patching it" up since it's a
>>>> more deep-seeded issue.
>>>>
>>>> Hope this helps,
>>>>
>>>> AT
>>>>
>>>>
>>>> On Wed, Jul 9, 2008 at 5:52 PM, Eric McGhee <emcghee73(a)gmail.com>
>>>> wrote:
>>>>
>>>>> Here are the files. I've also attached a list of the commands I've
>>>>> been running. Some of it is just me playing around with different options,
>>>>> but hopefully the important stuff will be clear enough.
>>>>>
>>>>> Thanks for your help!
>>>>>
>>>>> Eric
>>>>>
>>>>>
>>>>> On Wed, Jul 9, 2008 at 2:32 PM, Andrew C. Thomas <
>>>>> acthomas(a)fas.harvard.edu> wrote:
>>>>>
>>>>>> Eric, can you send me your data? I'll have a hack at it. -AT
>>>>>>
>>>>>>
>>>>>> On Wed, Jul 9, 2008 at 5:26 PM, Eric McGhee <emcghee73(a)gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> When I call the new.covariates command in judgeit, I get this error
>>>>>>> message:
>>>>>>>
>>>>>>> Error in if (dim(judgeit.object$covars[[year]])[2] !=
>>>>>>> dim(judgeit.object$covarsnew[[year]])[2]) stop("There is a different number
>>>>>>> of covariates in the new group compared to the old.") :
>>>>>>> argument is of length zero
>>>>>>> The command I'm trying to run is this:
>>>>>>>
>>>>>>> judgeit(routine= "svsum", judgeit.object=judg.obj,
>>>>>>> year=which(years==2006), new.covariates=list("regdf",regdf90s))
>>>>>>>
>>>>>>> where "regdf" is the actual party registration in the districts in
>>>>>>> 2006 and "regdf90s" is a vector of the average party registration in the
>>>>>>> 1990s. The data are California Assembly elections from 1992 to 2006. The
>>>>>>> judgeit object definition statement was:
>>>>>>>
>>>>>>>
>>>>>>> judg.obj <- judgeit(model.formula=dlegpr ~ inc + dexppr + regdf,
>>>>>>> data=elections, vote.formula=turnout~1, same.districts=same.dists,
>>>>>>> uncontesteds= "nochange", weight= "turnout")
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> where "dlgegpr" is the two-party vote, "inc" is incumbency, "dexppr"
>>>>>>> is spending, and "regdf" is party registration.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> If I set regdf to a specific scalar, like 0, the command works fine.
>>>>>>> It's only when I try to replace one variable with another that I run into
>>>>>>> problems. I've done some poking around, and it looks like the "$covars"
>>>>>>> object referenced in the error message exists but that the "$covarsnew"
>>>>>>> object remains undefined even after calling the new.covariates command. Any
>>>>>>> thoughts on what the problem might be? Both regdf and regdf90s have the
>>>>>>> same number of districts (80). I've tried using regdf90s as a simple vector
>>>>>>> (i.e., 80 cases long) and as a more complex list of vectors loaded in with
>>>>>>> the rest of the data (i.e., 80 cases X 8 election years).
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Any help would be much appreciated!
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Best,
>>>>>>>
>>>>>>> Eric McGhee
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
When I call the new.covariates command in judgeit, I get this error message:
Error in if (dim(judgeit.object$covars[[year]])[2] !=
dim(judgeit.object$covarsnew[[year]])[2]) stop("There is a different number
of covariates in the new group compared to the old.") :
argument is of length zero
The command I'm trying to run is this:
judgeit(routine= "svsum", judgeit.object=judg.obj, year=which(years==2006),
new.covariates=list("regdf",regdf90s))
where "regdf" is the actual party registration in the districts in 2006 and
"regdf90s" is a vector of the average party registration in the 1990s. The
data are California Assembly elections from 1992 to 2006. The judgeit
object definition statement was:
judg.obj <- judgeit(model.formula=dlegpr ~ inc + dexppr + regdf,
data=elections, vote.formula=turnout~1, same.districts=same.dists,
uncontesteds= "nochange", weight= "turnout")
where "dlgegpr" is the two-party vote, "inc" is incumbency, "dexppr" is
spending, and "regdf" is party registration.
If I set regdf to a specific scalar, like 0, the command works fine. It's
only when I try to replace one variable with another that I run into
problems. I've done some poking around, and it looks like the "$covars"
object referenced in the error message exists but that the "$covarsnew"
object remains undefined even after calling the new.covariates command. Any
thoughts on what the problem might be? Both regdf and regdf90s have the
same number of districts (80). I've tried using regdf90s as a simple vector
(i.e., 80 cases long) and as a more complex list of vectors loaded in with
the rest of the data (i.e., 80 cases X 8 election years).
Any help would be much appreciated!
Best,
Eric McGhee