forked from ICI3D/Sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MMED 2015-example.R
20 lines (18 loc) · 1.16 KB
/
MMED 2015-example.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#In an RCT of 1000 people, 500 received the experimental drug and the rest placebo
#Of the 500 who received treatment, 40 developed disease, while in the placebo group 60 developed disease
##Risk ratio of exposure:
RR <-(40/500)/(60/500) ##Ratio of Incidence of disease in the exposed Vs incidence of disease in unexposed
RR ##the Treatment is protective
#To obtain the probability of getting a result as extreme as the one observed, let's assume this follows a hypergeometric distribution, no bias, and sampling without replacement
sum(dhyper(0:40,500,500,100, log=F)) ## the result is significant
#probaility of getting >= 40 deaths
cbind(40:100,(dhyper(40:100,500,500,100, log=F)))
##Plotting probaility of getting >= 40 deaths
##Colour of graph changed to red
pdf(file.path('C:/Users/HP/Desktop/MMED2015/Sandbox','RR-plot.pdf'), w = 8, h = 11)
plot(seq(40,100), dhyper(40:100,500,500,100, log=F), xlab="No. who developed disease",
lines(seq(40,100), dhyper(40:100,500,500,100, log=F)))
abline(h=0.05,untf=F, col="red", lty=1, lwd=2) ## line showing statistical significance
dev.off()
###########continuation of the project######################## Sandile comment
# I am learning