You could try the forestplot() function in rmeta, or the original grid code on 
which it is based,
  http://www.stat.auckland.ac.nz/~paul/RGraphics/chapter1.html

    -thomas

On Mon, 19 Apr 2010, David Atkins wrote:


Hi all--

I am in the process of helping colleagues write up a ms in which we fit zero-inflated Poisson models. I would prefer plotting the rate ratios and 95% CI (as I've found Gelman and others convincing about plotting tables...), but our journals usually like the numbers themselves.

Thus, I'm looking at a recent JAMA article in which both numbers and dotplot of RR and 95% CI are presented and wondering about best way to do this in R.

Essentially, the plot has 3 columns: variable names, RR and 95% CI, and dotplot of the same.

Using the bioChemists data in the pscl package and errbar function in Hmisc package, the code below is in the right direction... but still pretty ugly.

Wondering if folks would have alternative suggestions about how to go about this, or pointers on cleaning up the code below (eg, I know there are many functions for plotting errbars/CI).

[And, obviously, there are somethings that would be straightforward to clean-up such as supplying better variable names, etc., just wanted to see if there were better overall suggestions before getting too far on this route.]

Thanks in advance.

cheers, Dave

library(Hmisc)
library(pscl)   

## data
data("bioChemists", package = "pscl")
fm_pois <- glm(art ~ ., data = bioChemists, family = poisson)
summary(fm_pois)

### pull out rate-ratios and 95% CI
rr <- exp(cbind(coef(fm_pois), confint(fm_pois)))
rr
### round to 2 decimal places
rr <- round(rr, 2)

### plot
par(mfrow=c(1,3))
plot(0, type = "n", xlim=c(0,2), ylim=c(1,6),
        axes = FALSE, ylab=NULL, xlab=NULL)
text(row.names(rr), x = 1, y = 1:6)

plot(0, type = "n", xlim=c(0,2), ylim=c(1,6),
        axes = FALSE, ylab=NULL, xlab=NULL)
text(paste(rr[,1], " [", rr[,2], ", ", rr[,3], "]", sep = ""), x = 1, y = 1:6)

errbar(x = factor(row.names(rr)),
                y = rr[,1], yplus = rr[,3],
                yminus = rr[,2])
abline(v = 1, lty =2)   

--
Dave Atkins, PhD
Research Associate Professor
Department of Psychiatry and Behavioral Science
University of Washington
datk...@u.washington.edu

Center for the Study of Health and Risk Behaviors (CSHRB)               
1100 NE 45th Street, Suite 300  
Seattle, WA  98105      
206-616-3879    
http://depts.washington.edu/cshrb/
(Mon-Wed)       

Center for Healthcare Improvement, for Addictions, Mental Illness,
 Medically Vulnerable Populations (CHAMMP)
325 9th Avenue, 2HH-15
Box 359911
Seattle, WA 98104?
206-897-4210
http://www.chammp.org
(Thurs)

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Thomas Lumley                   Assoc. Professor, Biostatistics
tlum...@u.washington.edu        University of Washington, Seattle

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to