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