Association among RR OR and IR

Keren Xu

2019/01/28

PDe<-c(0.01, seq(from=0.05, to=0.35, by=0.05))
RR<-seq(from=1.0, to=2.5, by=0.5)

computeOR <- function(a, b) {
    c <- (b-(b*a))/(1-(b*a))
    df<-data.frame(a,b,c)
    return(df) 
}

mylist<-sapply(PDe,computeOR,b=RR,simplify=FALSE) 
mydataframe<-do.call(rbind.data.frame, mylist)

names(mydataframe) <- c("PDe", "RR", "OR")
print(mydataframe)
##     PDe  RR        OR
## 1  0.01 1.0  1.000000
## 2  0.01 1.5  1.507614
## 3  0.01 2.0  2.020408
## 4  0.01 2.5  2.538462
## 5  0.05 1.0  1.000000
## 6  0.05 1.5  1.540541
## 7  0.05 2.0  2.111111
## 8  0.05 2.5  2.714286
## 9  0.10 1.0  1.000000
## 10 0.10 1.5  1.588235
## 11 0.10 2.0  2.250000
## 12 0.10 2.5  3.000000
## 13 0.15 1.0  1.000000
## 14 0.15 1.5  1.645161
## 15 0.15 2.0  2.428571
## 16 0.15 2.5  3.400000
## 17 0.20 1.0  1.000000
## 18 0.20 1.5  1.714286
## 19 0.20 2.0  2.666667
## 20 0.20 2.5  4.000000
## 21 0.25 1.0  1.000000
## 22 0.25 1.5  1.800000
## 23 0.25 2.0  3.000000
## 24 0.25 2.5  5.000000
## 25 0.30 1.0  1.000000
## 26 0.30 1.5  1.909091
## 27 0.30 2.0  3.500000
## 28 0.30 2.5  7.000000
## 29 0.35 1.0  1.000000
## 30 0.35 1.5  2.052632
## 31 0.35 2.0  4.333333
## 32 0.35 2.5 13.000000
library(ggplot2)
ggplot(mydataframe, aes(x = RR, y = OR, color=as.factor(PDe))) + 
  geom_line(size=2)+scale_y_continuous(limits = c(1,14) )+theme_classic()

computeIR <- function(a, b) {
  c=log(1-b*a)/log(1-a)
  df<-data.frame(a,b,c)
  return(df) 
}
mylist<-sapply(PDe,computeIR,b=RR,simplify=FALSE) 
mydataframe<-do.call(rbind.data.frame, mylist)

names(mydataframe) <- c("PDe", "RR", "IR")
print(mydataframe)
##     PDe  RR       IR
## 1  0.01 1.0 1.000000
## 2  0.01 1.5 1.503794
## 3  0.01 2.0 2.010152
## 4  0.01 2.5 2.519101
## 5  0.05 1.0 1.000000
## 6  0.05 1.5 1.519917
## 7  0.05 2.0 2.054080
## 8  0.05 2.5 2.603291
## 9  0.10 1.0 1.000000
## 10 0.10 1.5 1.542503
## 11 0.10 2.0 2.117905
## 12 0.10 2.5 2.730454
## 13 0.15 1.0 1.000000
## 14 0.15 1.5 1.568385
## 15 0.15 2.0 2.194667
## 16 0.15 2.5 2.891993
## 17 0.20 1.0 1.000000
## 18 0.20 1.5 1.598410
## 19 0.20 2.0 2.289224
## 20 0.20 2.5 3.106284
## 21 0.25 1.0 1.000000
## 22 0.25 1.5 1.633761
## 23 0.25 2.0 2.409421
## 24 0.25 2.5 3.409421
## 25 0.30 1.0 1.000000
## 26 0.30 1.5 1.676140
## 27 0.30 2.0 2.568980
## 28 0.30 2.5 3.886716
## 29 0.35 1.0 1.000000
## 30 0.35 1.5 1.728110
## 31 0.35 2.0 2.794848
## 32 0.35 2.5 4.827122
ggplot(mydataframe, aes(x = RR, y = IR, color=as.factor(PDe))) + 
  geom_line(size=2)+scale_y_continuous(limits = c(1,14) )+theme_classic()


References