Hi Casey,
Sorry that it took for a while, but I finally had a chance to look at
this. It looks like that your "dcode1" variable takes zero for all
observations. For example, the first imputed data set has:
Min. 1st Qu. Median
Mean 3rd Qu. Max.
0 0 0 0 0 0
As a consequence, the coefficient is not computed for this variable. For
example, try printing out:
summary(z.out[[1]])
In general, it might be a good idea to examine the model outputs for each
imputed data set in order to make sure that there is nothing strange going
on.
Hope this helps!
Kosuke
---------------------------------------------------------
Kosuke Imai Office: Corwin Hall 041
Assistant Professor Phone: 609-258-6601
Department of Politics eFax: 973-556-1929
Princeton University Email: kimai(a)Princeton.Edu
Princeton, NJ 08544-1012
---------------------------------------------------------
On Mon, 24 Mar 2008, Casey Klofstad wrote:
Kosuke-
Sorry for the belated response. I am sill having trouble with this. If
you are willing to try and replicate the error, the data sets are
attached. Code follows below.
Thanks!
-c
#START CODE
#load data
ds1 <- read.csv("match1.csv", header = TRUE)
ds2 <- read.csv("match2.csv", header = TRUE)
ds3 <- read.csv("match3.csv", header = TRUE)
ds4 <- read.csv("match4.csv", header = TRUE)
ds5 <- read.csv("match5.csv", header = TRUE)
#make subsets
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
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 x
x.untreat <- setx(z.out, treat = 0)
x.treat <- setx(z.out, treat = 1)
#expected values
untreat.out <- sim(z.out, x = x.untreat)
treat.out <- sim(z.out, x = x.treat)
#FD
FD.out <-sim(z.out, x = x.untreat, x1 = x.treat)
#delete subsets
tds1 <- NULL
tds2 <- NULL
tds3 <- NULL
tds4 <- NULL
tds5 <- NULL
#END CODE
On Tue, Mar 4, 2008 at 10:10 PM, Kosuke Imai <kimai(a)princeton.edu> wrote:
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: