530 likes | 560 Views
R for Statistics and Graphics. Session 5 Beyond Basic Statistics. Mehmet Tevfik DORAK, MD PhD School of Life Sciences, Pharmacy & Chemistry Kingston University London. Istanbul University, Capa Faculty of Medicine 19 April 2019. Outline. Statistical power Survival analysis
E N D
R for Statistics and Graphics Session 5 Beyond Basic Statistics Mehmet Tevfik DORAK, MD PhD School of Life Sciences, Pharmacy & Chemistry Kingston University London Istanbul University, Capa Faculty of Medicine 19 April 2019
Outline Statistical power Survival analysis Meta-analysis ROC analysis Resources for further study
Statistical Power Now, run Script: pwr.R
Survival Analysis survfit(Surv(survivaltime, event) ~ group, data = df) library("survival") data(leukemia) df <- leukemia df$survivaltime <- df$time df$event <- df$status df$group <- df$x head(df) fit <- survfit(Surv(survivaltime, event) ~ group, data = df) plot(fit) summary(fit) Script: survival.R
Meta-analysis Script: rmeta_Cochrane.R
Sensitivity / Specificity / PPV / NPV > install.packages(epiR) > library(epiR) > ct <- matrix(c(23,34,56,42), nrow=2) > ct [,1] [,2] [1,] 23 56 [2,] 34 42 > epi.tests(ct, conf.level = 0.95) Outcome + Outcome - Total Test + 23 56 79 Test - 34 42 76 Total 57 98 155 Point estimates and 95 % CIs: --------------------------------------------------------- Apparent prevalence 0.51 (0.43, 0.59) True prevalence 0.37 (0.29, 0.45) Sensitivity 0.40 (0.28, 0.54) Specificity 0.43 (0.33, 0.53) Positive predictive value 0.29 (0.19, 0.40) Negative predictive value 0.55 (0.43, 0.67) Positive likelihood ratio 0.71 (0.49, 1.01) Negative likelihood ratio 1.39 (1.02, 1.90) ---------------------------------------------------------
ROC Analysis in R > install.packages("pROC") # installing the package > library("pROC") # loading the package > jv <- read.csv("jv.csv") # reading the dataset > attach(jv) # specifying the dataset> rocjv <- roc(outcome, test) # performing the function> coords(rocjv, x="best", input="threshold", best.method="youden")
ROC Analysis • Cutoff value determination (Youden index): • jv <- read.csv("jv.csv")library("pROC")rocjv <- roc(jv$intubated, jv$wbc1)coords(rocjv, "best") • threshold specificity sensitivity 9.2000000 0.5801527 0.9523810 • coords(rocjv, x = "best", input = "threshold", • best.method = "youden") • threshold specificity sensitivity 9.2000000 0.5801527 0.9523810 • EXPLANATION: If WBC = 9200 is used as the cutoff for intubation risk, when WBC>9200, 58% of the time intubation occurs, and when WBC<9200, 95% of the time, intubation does not occur
ROC Analysis in R R code to generate a ROC curve for a 2x2 table: install.packages("psych") library("psych") AUC(c(n1, n2, n3, n4)) Included in the script: contingency.R
Running R Online https://www.tutorialspoint.com/execute_r_online.php Alternatives: https://rdrr.io/snippets http://www.roncloud.comhttp://www.compileonline.com/execute_r_online.phphttp://www.r-fiddle.orghttp://pbil.univ-lyon1.fr/Rweb/Rweb.general.html
R Studio Want to make life easier? Try R Studio, the most popular integrated development environment (IDE). Rstudio Cheet Sheet
R Commander For those of you who do not like to type a few lines of code….. … there is always R Commander!
More R Suggestions to Move Forward Cookbooks (online and in print) Websites and courses for "Using R" (not program development) MOOC courses R-Bloggers Search engines Courage and practice
Online Cookbooks for "Using R" WEB-BASED SOURCES http://www.dorak.info/mtd/glosstat.html R Tutorials @ ListenData: https://www.listendata.com/p/r-programming-tutorials.html
Resources http://www.r-clinical-research.com
R Books for Self-Learners My Top Recommendation
R Books for Statistics My Top Recommendation