problem with logical x-variable
I was just running an old script, and some Zelig commands that used to work are not working anymore (in Zelig 4.1-3).
The problem is with including a logical vector as an x-variable. The zelig() function works properly (with the logical vector treated as a 0:1 dummy). Things break down in setx(), which doesn't seem to convert the logical values into their numerical equivalents, resulting in a "model matrix" that is NA (and a "non-comformable arguments" error when fed to sim()).
A workaround is to enter the numerical equivalents of TRUE and FALSE in setx(), but it would be more intuitive to be able to enter the logical values directly, as in the past.
(Minimal working example below.)
Rod
## Minimal working example -- Zelig problem with logical x
require(Zelig)
df <- data.frame(y=rnorm(20),
xLogical=sample(c(TRUE, FALSE),
size=20,
replace=TRUE))
z.out <- zelig(y ~ xLogical, data=df, model="ls")
x.out <- setx(z.out, xLogical=FALSE)
summary(x.out) # model matrix is NA
s.out <- sim(z.out, x.out) # error: non-conformable arguments
## Workaround
x.out2 <- setx(z.out, xLogical=0)
summary(x.out2) # model matrix is OK
s.out <- sim(z.out, x.out2)
summary(s.out)
|
<div> <div>Hi,<br><br> I was just running an old script, and some Zelig commands that used to work are not working anymore (in Zelig 4.1-3).<br><br> The problem is with including a logical vector as an x-variable. The zelig() function works properly (with the logical vector treated as a 0:1 dummy). Things break down in setx(), which doesn't seem to convert the logical values into their numerical equivalents, resulting in a "model matrix" that is NA (and a "non-comformable arguments" error when fed to sim()).<br><br> A workaround is to enter the numerical equivalents of TRUE and FALSE in setx(), but it would be more intuitive to be able to enter the logical values directly, as in the past.<br><br> (Minimal working example below.)<br><br> Rod<br><br>## Minimal working example -- Zelig problem with logical x<br> require(Zelig)<br> df <- data.frame(y=rnorm(20),<br> xLogical=sample(c(TRUE, FALSE),<br> size=20,<br> replace=TRUE))<br> z.out <- zelig(y ~ xLogical, data=df, model="ls")<br> x.out <- setx(z.out, xLogical=FALSE)<br> summary(x.out) # model matrix is NA<br> s.out <- sim(z.out, x.out) # error: non-conformable arguments<br><br> ## Workaround<br> x.out2 <- setx(z.out, xLogical=0)<br> summary(x.out2) # model matrix is OK<br> s.out <- sim(z.out, x.out2)<br> summary(s.out) <br><br><br> </div> <table><tr><td bgcolor="#ffffff"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr> <td align="left"><span>This communication is intended for the addressee only. It is confidential. If you have received this communication in error, please notify us immediately and destroy the original message. You may not copy or disseminate this communication without the permission of the University. Only authorised signatories are competent to enter into agreements on behalf of the University and recipients are thus advised that the content of this message may not be legally binding on the University and may contain the personal views and opinions of the author, which are not necessarily the views and opinions of The University of the Witwatersrand, Johannesburg. All agreements between the University and outsiders are subject to South African Law unless the University agrees in writing to the contrary. </span></td> </tr></table></td></tr></table> </div>
RSS Feed