Hi,
OK, I downgraded to 3.5 so I can see what you're seeing. It seems that
you can put the weights vector in the global environment and it will
be picked up from there. To finish your example,
library(MatchIt)
library(Zelig) # must be 3.5.x
data(lalonde)
lalonde1=lalonde
w <- c(rep(0,100),rep(1,214),rep(2,300))
obj <- zelig(treat~black+married, model = "poisson", robust=T,
weights=w,data = mi(lalonde,lalonde1))
summary(obj)
HTH,
Ista
On Thu, Dec 13, 2012 at 9:04 PM, Pingaul jb <pingaultjb(a)yahoo.fr> wrote:
Dear Matt and Ista,
Ista, thanks for your suggestions, they solve part or the problem! To
summarize:
1/ Robust errors seem to work on version 3.5.5, so maybe sth to check on
version 4 (except for the weave option that produces unlikely small
standards errors on lalonde, but seemed to work fine on my data, not sure
why).
2/I got the use of quotes in weights =“w” in Ho et al, MatchIt, J of stat
Soft, 2011, 42(8). It works fine without robust errors and weights seem to
be taken into account. I tried weights = w and it did not work (maybe
version pb). However weights = lalonde$w worked and it also worked with
robust = T!! So part of my problem solved.
3/ As I need this to work with multiple data sets, my problem now is to
specify the weights for each imputed data set. If I use lalonde$w it will
take the weights in lalonde for all data set and won’t consider the proper
weights for each imputed data set (here lalonde and lalonde1). That’s why
the syntax weights= “w” was useful I think. I tried : weights =c(lalonde$w,
lalonde1$w) but did not work. If this can be solved hen I am good to go!
Below is the syntax corresponding to my points
Many Thanks!
#1/ Robust errors work with Zelig 3.5.5
data(lalonde)
#without robust, with default and vcovHAC (the same) and two other options
obj <- zelig(treat~black+married, model = "poisson", data = lalonde,cite=F)
obj1 <- zelig(treat~black+married, model = "poisson", robust=T, data =
lalonde,cite=F)
obj2 <- zelig(treat~black+married, model = "poisson",
robust=list(method="vcovHAC"), data = lalonde,cite=F)
obj3 <- zelig(treat~black+married, model = "poisson",
robust=list(method="kernHAC"), data = lalonde,cite=F)
obj4 <- zelig(treat~black+married, model = "poisson",
robust=list(method="weave"), data = lalonde,cite=F)
#standards errors are indeed different (weird unlikely results for
method="weave")
data.frame(summary(obj)$coefficients[,2],
summary(obj1)$coefficients[,2],
summary(obj2)$coefficients[,2],
summary(obj3)$coefficients[,2],
summary(obj4)$coefficients[,2])
#################################
#2/ INCLUSION OF WEIGHTS
lalonde$w=c(rep(1,300),rep(2,314))
#comparison model without weight
obj <- zelig(treat~black+married, model = "poisson",data = lalonde,cite=F)
summary(obj)
#weights with quotes
obj <- zelig(treat~black+married, model =
"poisson",weights="w",data =
lalonde,cite=F)
summary(obj)
#weights without quotes => error
obj <- zelig(treat~black+married, model = "poisson",weights=w,data =
lalonde,cite=F)
summary(obj)
#weights without quotes but identifying the data.frame
obj <- zelig(treat~black+married, model = "poisson",weights=lalonde$w,data
=
lalonde,cite=F)
summary(obj)
##Weights AND robust std errors
#with quotes, same error as I previously mentioned
obj <- zelig(treat~black+married, model = "poisson", robust=T,
weights="w",data = lalonde)
summary(obj)
#without quote it does work!! and the weights are indeed taken into account
obj <- zelig(treat~black+married, model = "poisson", robust=T,
weights=lalonde$w,data = lalonde)
summary(obj)
#Just to check, if I remove the robust=T, standard differences are indeed
different
#half the pb solved!
obj <- zelig(treat~black+married, model = "poisson",
weights=lalonde$w,data
= lalonde)
summary(obj)
#############################
#3/ multiple DATA SETS
lalonde1=lalonde
lalonde1$w=c(rep(0,100),rep(1,214),rep(2,300))
# How do I give every data sets its own vector of weights?
#If I do lalonde$w it will just use weights from lalonde and not lalonde 1
#tried the following but did not work
obj <- zelig(treat~black+married, model = "poisson", robust=T,
weights=c("lalonde$w","lalonde1$w"),data = mi(lalonde,lalonde1))