Hi, Timothy.
We fixed this problem several versions ago. Please make sure that you are running the
current version of Zelig (2.5-4) on the current version of R (2.2.2).
In addition, if you select cond = TRUE in setx(), you choose to calculate an average
treatment effect in sim(). If data are identical to the data used to run the model in
zelig(), the ATE will be effectively 0. I think you just want setx(z.out, fn = NULL).
Finally, the demo on p. 253 of the Zelig manual is not what you have below. We don't
generally have either conditional (cond = TRUE) or in-sample (fn = NULL) prediction in
demos simply because they take more time and demos should be short and compact.
Best,
Olivia Lau
----- Original Message -----
From: Humphrey, Timothy L. (LNG-DAY)
To: zelig(a)latte.harvard.edu
Sent: Thursday, April 20, 2006 4:06 PM
Subject: RE: [zelig] Error when using sim.
By the way, I got the same error when I used the data and zelig command in Example 1 on
page 253 of the Zelig manual, i.e. this is section 12.26 on relogit. Here is the code for
that attempt.
data(mid)
z.out1 <- zelig(conflict ~ major + contig + power +
maxdem + mindem + years, data=mid, model = "relogit", tau=1042/303772)
x.out1 <- setx(z.out1,data=mid, fn=NULL,cond=T)
s.out1 <- sim(z.out1, x=x.out1)
Error in yvar - qi$ev : non-conformable arrays
------------------------------------------------------------------------------
From: owner-zelig(a)mail-1.hmdc.harvard.edu [mailto:owner-zelig@mail-1.hmdc.harvard.edu]
On Behalf Of Humphrey, Timothy L. (LNG-DAY)
Sent: Thursday, April 20, 2006 3:29 PM
To: zelig(a)latte.harvard.edu
Subject: [zelig] Error when using sim.
I'm attempting to use relogit. I want to make a model then have the model predict
the outcome on test data. I was told that I can't use the R predict function to do
the prediction. So, I have been reading the manual to learn how to do prediction. After
reading the manual I produced the following code. But, when I run it, I always get an
error after running the sim function (See below)
z.out <- zelig(my.formula, data=LR.data, model =
"relogit", tau=0.05)
x.out <- setx(z.out, data=test.d, fn=NULL,
cond=TRUE)
s.out <- sim( z.out, x = x.out )
Error in yvar - qi$ev : non-conformable arrays
In the above example, x.out has 20 samples with 15 explanatory variables. In addition,
when I run sim with x.out having 10,000 samples, I get a memory limits exceeded error.
Below is what x.out looks like for the above example:
x.out
cbind(Y, 1 - Y).Y cbind(Y, 1 - Y).V2 X1 X2 X3 X4 X5 X6 X7 X8
1 0 1 0.0000 1.0 0 0 1.0 0.0 0.0000 0.0000
2 0 1 0.0000 0.5 0 0 0.5 0.0 0.0000 0.0000
3 0 1 0.1397 0.5 0 0 0.0 0.5 0.2732 1.0000
4 0 1 0.1397 0.0 0 0 0.0 0.0 0.0000 0.0000
5 0 1 0.0000 1.0 0 0 0.0 0.0 0.0000 0.0000
6 0 1 0.1397 0.5 0 0 0.0 0.5 0.2732 0.0000
7 0 1 0.1397 1.0 0 0 0.5 0.0 0.2732 0.0000
8 0 1 0.2708 1.0 0 0 0.0 0.0 0.0000 0.0664
9 0 1 0.1397 1.0 0 0 1.0 0.0 1.0000 0.0000
10 0 1 0.5270 0.0 0 1 0.0 0.0 0.2732 0.0000
11 1 0 0.0000 0.0 0 0 1.0 0.0 0.2732 0.0000
12 1 0 0.0000 1.0 0 1 1.0 0.0 0.0000 0.0000
13 1 0 0.7583 0.0 0 1 0.5 0.5 0.2732 1.0000
14 1 0 0.1328 0.0 0 0 1.0 0.0 0.0000 0.0000
15 1 0 0.5270 0.0 0 0 0.0 0.0 1.0000 0.0000
16 1 0 0.1328 0.0 0 1 0.0 0.0 0.0000 0.0000
17 1 0 0.0000 1.0 0 0 0.0 0.0 0.0000 0.0000
18 1 0 0.5270 0.5 0 0 1.0 0.0 1.0000 0.0000
19 1 0 1.0000 0.0 0 1 0.0 0.5 1.0000 0.0664
20 1 0 1.0000 0.0 0 0 0.0 0.0 1.0000 0.0000
X9 X10 X11 X12 X13 X14 X15
1 0 0.0000 0.2700 0.1506 0.2498 0.5077 0
2 0 0.0000 0.0601 0.0000 0.1683 0.5077 0
3 0 0.0000 0.0424 0.1506 0.3022 0.7333 0
4 0 0.0000 0.1316 0.3939 0.1417 0.5077 0
5 0 0.1576 0.7785 0.0000 0.2882 0.3143 0
6 0 0.0000 0.0601 0.7959 0.2845 0.5077 0
7 0 0.1576 0.4845 0.0000 0.0231 0.3143 0
8 0 0.0000 0.4061 0.1506 0.0000 0.0000 0
9 0 0.0000 0.3014 0.2063 0.0264 0.5077 1
10 0 0.0000 0.3014 0.4643 0.3881 0.1467 0
11 0 0.0000 0.2034 0.5392 0.2418 0.5077 1
12 0 0.0000 0.1388 0.0000 0.1025 0.1467 0
13 1 0.0000 0.0508 0.2063 0.3312 0.5077 0
14 0 0.0000 0.2215 0.0476 0.2499 0.5077 0
15 0 0.1576 0.6463 0.1506 0.2182 0.5077 0
16 0 0.1576 0.3346 0.4643 0.7887 0.5077 0
17 0 0.1576 0.4845 0.0000 0.0350 0.1467 0
18 0 0.0000 0.0984 0.1506 0.0714 0.1467 0
19 0 0.0000 0.1462 0.0000 0.0000 0.0000 0
20 0 0.0000 0.1777 0.3277 0.3560 0.7333 0