Hi Casey,
It looks like that the current infrastructure of Zelig does not allow
the simultaneous use of "by" command with multiple imputation... We hope
to figure that out in the future though.
Sorry!
Kosuke
On Wed, 13 Feb 2008, Casey Klofstad wrote:
Ok, here is the code and what happens:
z.out <- zelig(civtotw2 ~ treat + civtotw1 + dcode1 + dcode3 + dcode4
+ dcode5 + dcode6 + dcode7 + dcode8 + dcode9 + dcode10 + dcode11 +
dcode12 + dcode13 + dcode14 + dcode15 + dcode16, weights="weights",
data = mi(ds1, ds2, ds3, ds4, ds5), model = "ls", by = "civw1_q")
#this ran successfully; note that the "civw1_q" factor is an ordinal
four-point scale
x.untreat <- setx(z.out, treat = 0)
#this also ran successfully
untreat.out <- sim(z.out, x = x.untreat)
#this failed; here is the traceback:
9: stop("incompatible arguments")
8: mvrnorm(num, mu = coef(object), Sigma = vcov(object))
7: param.lm(object[[i]], num = numM, bootstrap = bootstrap)
6: param(object[[i]], num = numM, bootstrap = bootstrap)
5: MIsimulation(object, num, prev, bootstrap, bootfn = bootfn, x = x,
x1 = x1, ...)
4: sim.setx.MI(object[[i]], x = x[[i]], x1 = x1[[i]], num = numN,
bootstrap = bootstrap, ...)
3: sim(object[[i]], x = x[[i]], x1 = x1[[i]], num = numN, bootstrap =
bootstrap, ...)
2: sim.setx.strata(z.out, x = x.untreat)
1: sim(z.out, x = x.untreat)
I get the same problem even if I don't weight the data.
Another complication (or bit of evidence) is after I ran the above, I
ran a piece of code that should work. It is the same model, onyl
without the "by" command. The model runs fine, but when I get to
"setx" I get this:
Error in value[[jj]][ri] <- if (is.factor(xij)) as.vector(xij) else
xij : nothing to replace with
traceback()
4: rbind(deparse.level, ...)
3: rbind(dta, tmp)
2: setx.MI(z.out, treat = 0)
1: setx(z.out, treat = 0)
If I close R and rerun the above, it works.
Thoughts? Thanks!
-c
On Feb 13, 2008 2:03 PM, Olivia Lau <olau(a)fas.harvard.edu> wrote:
> Casey, after the sim command (when you get the error),
>
> can you tell me the output you get when you do:
>
traceback()
>
> ?
>
> Also, try it without weights. Thx, O
>
>
>
> On Feb 13, 2008 11:05 AM, Casey Klofstad <klofstad(a)gmail.com> wrote:
>
>> Yeah, the demo works for me too.
>>
>> Here is what I am trying to run:
>>
>> #START CODE
>>
>> z.out <- zelig(civtotw2 ~ treat + civtotw1 + dcode1 + dcode3 + dcode4
>> + dcode5 + dcode6 + dcode7 + dcode8 + dcode9 + dcode10 + dcode11 +
>> dcode12 + dcode13 + dcode14 + dcode15 + dcode16, weights="weights",
>> data = mi(ds1, ds2, ds3, ds4, ds5), model = "ls", by =
"civw1_q")
>>
>> x.untreat <- setx(z.out, treat = 0)
>>
>> x.treat <- setx(z.out, treat = 1)
>>
>> #note: the code appears to work fine until I get to the "sim" stage;
>> that is where I get the error "Error in mvrnorm(num, mu =
>>
>> coef(object), #Sigma = vcov(object)) : incompatible arguments"
>>
>> untreat.out <- sim(z.out, x = x.untreat)
>>
>> treat.out <- sim(z.out, x = x.treat)
>>
>> FD.out <-sim(z.out, x = x.untreat, x1 = x.treat)
>>
>> #END CODE
>>
>> I'm sure I'm missing something obvious here, so thanks very much for
>> your indulgence.
>>
>> Best,
>>
>> -c
>>
>>
>>
>>
>> On Feb 13, 2008 10:56 AM, Kosuke Imai <kimai(a)princeton.edu> wrote:
>>> demo(strata) works for us and so maybe you can send us the code so that
> we
>>> can see what the problem is?
>>>
>>> Thanks,
>>> Kosuke
>>>
>>>
>>> On Wed, 13 Feb 2008, Casey Klofstad wrote:
>>>
>>>> I'm using simple OLS. Also, I just updated from 3.0-6 to 3.1-0.
That
>>>> does not appear to fix the issue.
>>>>
>>>> Is it just the case that I can't run "sim" on a series of
models that
>>>> were generated with the "by" command? Or am I missing something
here?
>>>>
>>>> Thanks much,
>>>>
>>>> -c
>>>>
>>>> On Feb 12, 2008 11:07 PM, Kosuke Imai <kimai(a)princeton.edu> wrote:
>>>>> Which model are you using? Also, did you try the latest release?
>>>>>
>>>>> Kosuke
>>>>>
>>>>>
>>>>> On Tue, 12 Feb 2008, Casey Klofstad wrote:
>>>>>
>>>>>> I am able to estimate my model using the "by" command
in zelig to
> run
>>>>>> a model n times for n different values of a variable of
interests. I
>>>>>> am also able to then run "setx" without any errors.
>>>>>>
>>>>>> The problem comes when I try to run "sim." I get the
error: "Error
> in
>>>>>> mvrnorm(num, mu = coef(object), Sigma = vcov(object)) :
incompatible
>>>>>> arguments."
>>>>>>
>>>>>> Maybe I am missing something obvious here. Thoughts?
>>>>>>
>>>>>> Thanks much!
>>>>>>
>>>>>> -c
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>>
>>
>>
>>
>> --
>> Casey A. Klofstad
>> University of Miami
>> Department of Political Science
>> Coral Gables, FL
>>
>> klofstad(a)gmail.com
>>
http://moya.bus.miami.edu/~cklofstad
>>
>
>
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: