Hi,
You must use the variable names that are in the original data frame. So,
in your example, this line
z.out <- zelig(y ~ fac, model="logit",
data=myData)
should be
z.out <- zelig(cbind(y.y, y.V2) ~ fac,
model="logit", data=myData)
and then setx() works (though in this case there is a warning because the
variable has multiple modes):
x0 <- setx(z.out, fac="1")
Warning
message:
There is more than one mode. The first level is selected. in: FUN(X[[1]],
...)
x0
(Intercept) fac2
1 1 0
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
http://imai.princeton.edu
-----------------------------------------------------
On Sun, 8 Apr 2007, Gregor Gorjanc wrote:
> Hello I am having a problem with setx() with binomial model i.e.
>
> y ~ Binomial(p, k)
>
> where k is number of possible successes. I am providing an reproducible
> example bellow.
>
> <code r>
> ## --- Generate data ---
> ## Number of possible successes
> k <- 25
> ## Probabilities
> p <- c(0.2, 0.7)
> ## Number of records
> n <- 200
> y <- rbinom(n=n, size=k, prob=p)
> y <- cbind(y, k - y)
> fac <- as.factor(rep(1:length(p), times=(n / length(p))))
> myData <- data.frame(y=y, fac=fac)
>
> ## --- Model ---
>
z.out <- zelig(y ~ fac, model="logit",
data=myData)
> summary(z.out)
>
> tmp <- glm(y ~ fac, data=myData, family=binomial)
> summary(tmp)
>
> ## --> OK
>
> ## --- Inferences ---
>
> x.out <- setx(z.out, fn=NULL)
> s.out <- sim(z.out, x=x.out)
> summary(s.out)
>
> ## --> OK
>
x0 <- setx(z.out, fac="1")
>
> Error in model.frame(formula, rownames, variables, varnames, extras,
> extranames, :
> variable lengths differ (found for 'fac')
> In addition: Warning message:
> There is more than one mode. The first level is selected. in: FUN(X[[1]], ...)
>
> x1 <- setx(z.out, fac="2")
> fac1 <- sim(z.out, x=x0)
> fac2 <- sim(z.out, x=x1)
> facDiff <- sim(z.out, x=x0, x1=x1)
>
> </code r>
>
> Is it possible to overcome this problem?
>
> Thank you, Gregor
>
> -
> 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/
>
-
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/