James,
Thanks for your prompt reply and the function to solve my question. With a couple of extra
lines of code to add the simulated risk ratio to the output, I obtained the needed
confidence intervals-
##Working to add RR to simulation output- s.out.2
rr<- s.out.2$qi[[2]]/s.out.2$qi[[1]]#Risk ratio
s.out.2$qi<- list("Risk Ratio"=rr)
print(myci(s.out.2))##CI RR
rr.num<- as.numeric(rr)
mean(rr.num)#RR point est.
Kind regards,
Chris
-----Original Message-----
From: Honaker, James [mailto:jhonaker@iq.harvard.edu]
Sent: Thursday, 19 December 2013 12:46 p.m.
To: Chris Compton; zelig(a)lists.gking.harvard.edu
Subject: RE: Obtaining risk ratio from simulation output
Chris,
Exactly which quantities of interest exist, are model dependent. I believe this has
always been so. Thus risk ratios may have been provided by the author of one model for
Zelig, and not by the author who set up a different model. It may also be the case that
some models previously had risk ratios, and those were omitted when ported from Zelig 3 to
Zelig 4. If there is a particular model or set of models you want risk ratios in Zelig 4
for, let me know, and I'll go in and add them.
The current summary() command of a zelig object has caused several commentators to write.
I'll try to amalgamate these suggestions and problems into a fix in the near future.
If you need confidence intervals in the meantime, here is a utility function you could put
in your code and use:
myci<-function(z,ci=.95){
n<-length(z$qi[[1]])
cimatrix<-matrix(NA, nrow=length(z$qi), ncol=2)
for(i in 1:length(z$qi)){
ordered.qi<-sort(z$qi[[i]])
cimatrix[i,1]<-ordered.qi[ max(round(n*(1-ci)),1) ]
cimatrix[i,2]<-ordered.qi[ round(n*ci) ]
}
return(cimatrix)
}
where "z" is the output of the sim() function. For example:
library(zelig)
data(turnout)
z.out <- zelig(vote ~ race + educate + age + I(age^2) + income, model =
"logit", data = turnout) x.low <- setx(z.out, educate = 12) x.high <-
setx(z.out, educate = 16) s.out <- sim(z.out, x = x.low, x1 = x.high)
print(myci(s.out))
James
--
James Honaker, Senior Research Scientist
//// Institute for Quantitative Social Science, Harvard University
________________________________________
From: zelig-bounces(a)lists.gking.harvard.edu [zelig-bounces(a)lists.gking.harvard.edu] on
behalf of Chris Compton [CCompton(a)anexa.co.nz]
Sent: Wednesday, December 18, 2013 5:58 PM
To: zelig(a)lists.gking.harvard.edu
Subject: [zelig] Obtaining risk ratio from simulation output
Dear List Members,
In a previous version of Zelig (unsure of version number) it was possible to extract both
the first difference and risk ratio from the summary () function, as in the below steps
Model:
z.out.1 <- zelig(bhbahi~treatment+agecat+breedcat+herd_initials, model =
"logit", data = dat)
Simulated quantities of interest:
x.0 <- setx(z.out.1, treatment = "Control")
x.1 <- setx(z.out.1, treatment = "Treatment")
s.out.2 <- sim(z.out.1, x = x.0, x1 = x.1)
Summary of first difference and risk ratio
summary(s.out.2)
However, changes have removed risk ratio from the quantities of interest and summary ()
output. The $qi now contains only:
names(s.out.2$qi)
[1] "Expected Values:
E(Y|X)" "Expected Values: E(Y|X1)"
[3] "Predicted Values: Y|X" "Predicted Values: Y|X1"
[5] "First Differences: E(Y|X1) - E(Y|X)"
My question is- is there a convenient way to obtain risk ratios and confidence intervals
with the new version?
I am running Zelig version 4.2-1 on R version 3.0.2 on a Windows 7 platform
Thanks for any help.
Chris Compton
-
--
Zelig Mailing List, served by HUIT
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options:
http://lists.gking.harvard.edu/mailman/listinfo/zelig
Zelig program information:
http://gking.harvard.edu/zelig/
Zelig mailing list
Zelig(a)lists.gking.harvard.edu
To unsubscribe from this list or get other information:
https://lists.gking.harvard.edu/mailman/listinfo/zelig