Casey,
A couple of points on this:
First, an example for the use of both multiple imputation and "by"
command is given in demo(mi). There is an error we need to fix regarding
summary(), but at least for some models, "by" command can be used with
multiply imputed data sets. So, we may want to revisit the initial problem
you had. If you are interested, send us your data and code so that we can
replicate your error.
I'm not 100% sure what the problem below is. It might be that some
variables are perfectly collinear in some of the multiply imputed data
sets. But, without the data, I can't quite diagnose the problem.
Kosuke
On Mon, 3 Mar 2008, Casey Klofstad wrote:
Hey all-
Based on a prior post, we found out that Zelig does not support
simulations with the "by" command. So, to address this, I'm trying to
do this "manually" using the subset command to select cases.
Unfortunately, this has also led to errors.
Here is what I did:
#select cases for each imputed data set
tds1 <- subset(ds1, civw1_q==2)
tds2 <- subset(ds2, civw1_q==2)
tds3 <- subset(ds3, civw1_q==2)
tds4 <- subset(ds4, civw1_q==2)
tds5 <- subset(ds5, civw1_q==2)
#run model with selected cases
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(tds1, tds2, tds3, tds4, tds5), model = "ls")
#set values
x.untreat <- setx(z.out, treat = 0)
#generate expected values
untreat.out <- sim(z.out, x = x.untreat)
Ok, so everything runs as expected until this final step fails. The error is:
Error in mvrnorm(num, mu = coef(object), Sigma = vcov(object)) :
incompatible arguments
Traceback says:
7: stop("incompatible arguments")
6: mvrnorm(num, mu = coef(object), Sigma = vcov(object))
5: param.lm(object[[i]], num = numM, bootstrap = bootstrap)
4: param(object[[i]], num = numM, bootstrap = bootstrap)
3: MIsimulation(object, num, prev, bootstrap, bootfn = bootfn, x = x,
x1 = x1, ...)
2: sim.setx.MI(z.out, x = x.untreat)
1: sim(z.out, x = x.untreat)
What am I missing here? One thing to note is that the sizes of the
data sets differ by a few cases. This is becuase the number of cases
where "civw1_q==2" differs based on the imputed values. Could that be
the issue?
Thanks much,
-c
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options:
http://lists.gking.harvard.edu/?info=zelig
Zelig program information:
http://gking.harvard.edu/zelig/