[R] Re: your mail

Thomas Lumley thomas at biostat.washington.edu
Thu Sep 14 22:39:35 CEST 2000


On Thu, 14 Sep 2000, Troels Ring wrote:

> Dear friends.
> 
> I wanted to get an impression of the odds ratio of two treatments:
> 1) 11 survival 4 deaths
> 2) 5 survival 9 deaths
> I know I could use
> library(ctest)
> s <- 
> matrix(c(11,4,5,9),nr=2,dimnames=list(c("Survived","Death"),c("New","Standard")))
> fisher.test(s)
> to get a p value of 0.0656  and 95% CI of OR of
> 0.8108857 32.5251110
> but wanted instead a bayesian estimate using prior beta(1,1) for both 
> treatments.
> 
> I came up with
> x1 <- seq(0,1,by=0.01)
> x2 <- seq(0,1,by=0.01)
> post1 <- dbeta(x1,12,5)
> post2 <- dbeta(x2,6,10)
> ORR <- (post1/(1-post1))/(post2/(1-post2))
> ORR <- ORR[!is.na(ORR)]
> but this did not behave well at all.
> I thought I would get about the same mean for OR (4.656126) as with Fisher 
> test - but not at all.
> How can I sample from the distribution of the OR in a proper way ?

If the priors are independent Beta(1,1) then the posteriors are
independent Beta(12,5) and Beta(6,10), so you can eg

p1<-rbeta(1000,12,5)
p2<-rbeta(1000,6,10)

OR<-p1*(1-p2)/(p2*(1-p1))

You might also find it illuminating to sample from your prior.

	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list