IQSS / Zelig4

Old version of the statistical package Zelig, v4.x. New version is in the Zelig repo.
GNU General Public License v2.0
15 stars 6 forks source link

pooled results differ from Zelig 3.5 #44

Open whatever opened 11 years ago

whatever commented 11 years ago

Pooled results work differently than in Zelig 3.5. This needs both a tweak and a documentation change

 library(Zelig)
 obs <- 1000
 dat <- data.frame(cbind(rnorm(obs), runif(obs)))
 names(dat) <- c("myX1", "myX2")

 dat$myY <- dat$myX1 + 2*dat$myX2 - dat$myX1*dat$myX2 + rnorm(obs)

 m1 <- zelig(myY ~ myX1 + myX2 + myX1:myX2, data = dat, model = "ls")
 x.out <- setx(m1, myX1 = 2:3, myX2 = .4)
 x.out2 <- setx(m1, myX1 = 2:3, myX2 = .6)
 s.out <- sim(m1, x = x.out, x1 = x.out2)
 s.out$qi$fd
mjdonnelly commented 11 years ago

This may be related to issue #48, but I'm not sure.

The updated first differences appears to work for a single pair of observations, but not across a range:

Data prep

obs <- 1000 dat <- data.frame(cbind(rnorm(obs), runif(obs))) names(dat) <- c("myX1", "myX2") grps <- c("g1", "g2", "g3") dat$grp <- as.factor(sample(grps, obs, replace = TRUE))

dat$myY <- dat$myX1 + 2_dat$myX2 - dat$myX1_dat$myX2 + rnorm(obs)

fit model

m1 <- zelig(myY ~ myX1 + myX2 + myX1:myX2 + grp, data = dat, model = "ls")

Single pair of observations

x.out <- setx(m1, myX1 = 1, myX2 = .4) x.out2 <- setx(m1, myX1 = 1, myX2 = .6) s.out <- sim(m1, x = x.out, x1 = x.out2)

test <- simulation.matrix(s.out, "First Differences") summary(test)

Multiple pairs of observations

x.out <- setx(m1, myX1 = 1:2, myX2 = .4) x.out2 <- setx(m1, myX1 = 1:2, myX2 = .6) s.out <- sim(m1, x = x.out, x1 = x.out2)

test <- simulation.matrix(s.out, "First Differences") summary(test)